filters
concat 2 strings: {{ "hello "|add:"john doe" }}
capitalize: {{ "hello there!"|capfirst }}
capitalize each word: {{ "hello there!"|title }}
default value: {{ simple.nothing|default:"n/a" }}
default only if nil: {{ nil|default_if_none:"n/a" }}
variable is safe: {{ var|safe }}
truncate string: {{ "Joel is a slug"|truncatechars:9 }} -> Joel i...
pluralize: customer{{ 2|pluralize }}
urlencode: {{ "http://www.example.org/foo?a=b&c=d"|urlencode }}
convert to integer: {{ var|integer }}
join a list of string: {{ items | join:", " }}
newline to <br>: {{ var | linebreaks | safe }}
escape var for js: {{ var | escapejs }}
reference:
https://github.com/flosch/pongo2/blob/master/template_tests/filters.tpl
Last updated