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.
§Note
All result types of any filter function in this module is subject to change at any
point, and is not indicated by as semver breaking version bump.
The traits AutoEscape and WriteWritable are used by [askama_derive]’s generated code
to work with all compatible types.
Structs§
- Auto
Escaper - Used internally by askama to select the appropriate escaper
- Html
- Escape characters in a safe way for HTML texts and attributes
- Html
Safe Output - Like
Safe, but only for HTML output - Safe
- Mark the output of a filter as “safe”
- Text
- Don’t escape the input but return in verbatim
- Unsafe
- There is not need to mark the output of a custom filter as “unsafe”; this is simply the default
- Writable
- Used internally by askama to select the appropriate
write!()mechanism
Enums§
- Maybe
Safe - Mark the output of a filter as “maybe safe”
Traits§
- AsIndent
alloc - A prefix usable for indenting prettified JSON data and
|indent - Auto
Escape - Used internally by askama to select the appropriate escaper
- Escaper
- Escapers are used to make generated text safe for printing in some context.
- Html
Safe - Types that implement this marker trait don’t need to be HTML escaped
- Pluralize
Count - An integer that can have the value
+1and maybe-1. - Write
Writable - Used internally by askama to select the appropriate
write!()mechanism
Functions§
- capitalize
alloc - Capitalize a value. The first character will be uppercase, all others lowercase.
- center
- Centers the value in a field of a given width
- e
- Alias for
escape() - escape
- Escapes strings according to the escape mode.
- filesizeformat
- Returns adequate string representation (in KB, ..) of number of bytes
- fmt
alloc - Formats arguments according to the specified format
- format
alloc - Formats arguments according to the specified format
- indent
alloc - Indent lines with spaces or a prefix.
- join
- Joins iterable into a string separated by provided argument
- json
serde_json - Serialize to JSON (requires
jsonfeature) - json_
pretty serde_json - Serialize to formatted/prettified JSON (requires
jsonfeature) - linebreaks
alloc - Replaces line breaks in plain text with appropriate HTML
- linebreaksbr
alloc - Converts all newlines in a piece of plain text to HTML line breaks
- lower
alloc - Converts to lowercase
- lowercase
alloc - Converts to lowercase, alias for the
|lowerfilter - paragraphbreaks
alloc - Replaces only paragraph breaks in plain text with appropriate HTML
- pluralize
- For a value of
±1by default an empty string""is returned, otherwise"s". - safe
- Marks a string (or other
Displaytype) as safe - title
alloc - Return a title cased version of the value. Words will start with uppercase letters, all remaining characters are lowercase.
- titlecase
alloc - Return a title cased version of the value. Alias for the
|titlefilter. - trim
alloc - Strip leading and trailing whitespace
- truncate
- Limit string length, appends ‘…’ if truncated
- unique
std - Returns an iterator with all duplicates removed.
- upper
alloc - Converts to uppercase
- uppercase
alloc - Converts to uppercase, alias for the
|upperfilter - urlencode
urlencode - Percent-encodes the argument for safe use in URI; does not encode
/. - urlencode_
strict urlencode - Percent-encodes the argument for safe use in URI; encodes
/. - wordcount
alloc - Count the words in that string.