Filters
Maizzle includes filters that enable you to do anything you want to text nodes inside elements that you mark with custom attributes.Usage
Add afilters object to your Maizzle config:
config.js
key: value pair.
keyrepresents a custom HTML attribute namevalueis a function that accepts two arguments, and must return a string
config.js
emails/example.html
- compile CSS in some
<style>tag with Sass or others - normalize html whitespace in parts of your code
- create various content filters
- …
Disabling
You may disable all filters by setting the option tofalse:
config.js
Default filters
The following filters are included by default.append
Append text to the end of the string.example.html
prepend
Prepend text to the beginning of the string.example.html
uppercase
Uppercase the string.example.html
lowercase
Lowercase the string.example.html
capitalize
Uppercase the first letter of the string.example.html
ceil
Round up to the nearest integer.example.html
floor
Round down to the nearest integer.example.html
round
Round to the nearest integer.example.html
escape
Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example).example.html
escape-once
Escapes a string without changing existing escaped entities.example.html
lstrip
Remove leading whitespace from the string.example.html
rstrip
Remove trailing whitespace from the string.example.html
trim
Remove leading and trailing whitespace from the string.example.html
minus
Subtracts one number from another.example.html
plus
Adds one number to another.example.html
multiply
Alias:times
example.html
divide-by
Alias:divide
example.html
modulo
Returns the remainder of one number divided by another.example.html
newline-to-br
Insert an HTML line break (<br />) in front of each newline (\n) in a string.
example.html
strip-newlines
Remove any newline characters (line breaks) from the string.example.html
remove
Remove every occurrence oftext from the string.
example.html
remove-first
Remove the first occurrence oftext from the string.
example.html
replace
Replace every occurrence of the first argument with the second argument. You must separate arguments with a pipe character (|).
example.html
replace-first
Replace the first occurrence of the first argument with the second argument. You must separate arguments with a pipe character (|).
example.html
size
Return the number of characters in the string.example.html
slice
Return a slice of the string starting at the provided index.example.html
example.html
truncate
Shorten a string down to the number of characters passed as the argument.example.html
example.html
truncate-words
Shorten a string down to the number of words passed as the argument.example.html
example.html
url-decode
Decode a string that has been encoded as a URL.example.html
url-encode
Convert any URL-unsafe characters in a string into percent-encoded characters.example.html