Expand description
Module for built-in filter functions
Contains all the built-in filter functions for use in templates. You can define your own filters, as well. For more information, read the book.
Functions§
- abs
- Absolute value
- capitalize
- Capitalize a value. The first character will be uppercase, all others lowercase.
- center
- Centers the value in a field of a given width
- escape
- Escapes strings according to the escape mode.
- filesizeformat
- Returns adequate string representation (in KB, ..) of number of bytes
- fmt
- Formats arguments according to the specified format
- format
- Formats arguments according to the specified format
- indent
- Indent lines with
width
spaces - into_
f64 - Casts number to f64
- into_
isize - Casts number to isize
- join
- Joins iterable into a string separated by provided argument
- json
- Serialize to JSON (requires
json
feature) - linebreaks
- Replaces line breaks in plain text with appropriate HTML
- linebreaksbr
- Converts all newlines in a piece of plain text to HTML line breaks
- lower
- Converts to lowercase
- lowercase
- Alias for the
lower()
filter - paragraphbreaks
- Replaces only paragraph breaks in plain text with appropriate HTML
- safe
- Marks a string (or other
Display
type) as safe - trim
- Strip leading and trailing whitespace
- truncate
- Limit string length, appends ‘…’ if truncated
- upper
- Converts to uppercase
- uppercase
- Alias for the
upper()
filter - urlencode
- Percent-encodes the argument for safe use in URI; does not encode
/
. - urlencode_
strict - Percent-encodes the argument for safe use in URI; encodes
/
. - wordcount
- Count the words in that string
- yaml
- Serialize to YAML (requires
serde_yaml
feature)