Module askama::filters

source ·
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§

  • Used internally by askama to select the appropriate escaper
  • Escape characters in a safe way for HTML texts and attributes
  • Like Safe, but only for HTML output
  • Mark the output of a filter as “safe”
  • Don’t escape the input but return in verbatim
  • There is not need to mark the output of a custom filter as “unsafe”; this is simply the default
  • Used internally by askama to select the appropriate write!() mechanism

Enums§

  • Mark the output of a filter as “maybe safe”

Traits§

  • AsIndentserde_json
    A prefix usable for indenting prettified JSON data
  • Used internally by askama to select the appropriate escaper
  • Escapers are used to make generated text safe for printing in some context.
  • Used internally by askama to speed up writing some types.
  • Types that implement this marker trait don’t need to be HTML escaped
  • An integer that can have the value +1 and maybe -1.
  • Used internally by askama to select the appropriate write!() mechanism

Functions§

  • Capitalize a value. The first character will be uppercase, all others lowercase.
  • Centers the value in a field of a given width
  • Alias for escape()
  • Escapes strings according to the escape mode.
  • Returns adequate string representation (in KB, ..) of number of bytes
  • fmtalloc
    Formats arguments according to the specified format
  • formatalloc
    Formats arguments according to the specified format
  • indentalloc
    Indent lines with width spaces
  • Joins iterable into a string separated by provided argument
  • jsonserde_json
    Serialize to JSON (requires json feature)
  • json_prettyserde_json
    Serialize to formatted/prettified JSON (requires json feature)
  • Replaces line breaks in plain text with appropriate HTML
  • Converts all newlines in a piece of plain text to HTML line breaks
  • loweralloc
    Converts to lowercase
  • Converts to lowercase, alias for the |lower filter
  • Replaces only paragraph breaks in plain text with appropriate HTML
  • For a value of ±1 by default an empty string "" is returned, otherwise "s".
  • Marks a string (or other Display type) as safe
  • titlealloc
    Return a title cased version of the value. Words will start with uppercase letters, all remaining characters are lowercase.
  • trimalloc
    Strip leading and trailing whitespace
  • Limit string length, appends ‘…’ if truncated
  • upperalloc
    Converts to uppercase
  • Converts to uppercase, alias for the |upper filter
  • urlencodeurlencode
    Percent-encodes the argument for safe use in URI; does not encode /.
  • Percent-encodes the argument for safe use in URI; encodes /.
  • Count the words in that string.