jinja2.filters

jinja2.filters

Bundled jinja filters.

copyright:
  1. 2010 by the Jinja Team.
license:

BSD, see LICENSE for more details.

Exceptions

FilterArgumentError([message]) This error is raised if a filter was called with inappropriate
SecurityError([message]) Raised if a template tries to do something insecure if the

Functions

contextfilter(f) Decorator for marking context dependent filters.
do_attr(environment, obj, name) Get an attribute of an object.
do_batch(value, linecount[, fill_with]) A filter that batches items.
do_capitalize(s) Capitalize a value.
do_center(value[, width]) Centers the value in a field of a given width.
do_default(value[, default_value, boolean]) If the value is undefined it will return the passed default value, otherwise the value of the variable: ..
do_dictsort(value[, case_sensitive, by]) Sort a dict and yield (key, value) pairs.
do_filesizeformat(value[, binary]) Format the value like a ‘human-readable’ file size (i.e.
do_first(environment, seq) Return the first item of a sequence.
do_float(value[, default]) Convert the value into a floating point number.
do_forceescape(value) Enforce HTML escaping. This will probably double escape variables.
do_format(value, *args, **kwargs) Apply python string formatting on an object: ..
do_groupby(environment, value, attribute) Group a sequence of objects by a common attribute.
do_indent(s[, width, indentfirst]) Return a copy of the passed string, each line indented by 4 spaces.
do_int(value[, default]) Convert the value into an integer.
do_join(eval_ctx, value[, d, attribute]) Return a string which is the concatenation of the strings in the sequence.
do_last(environment, seq) Return the last item of a sequence.
do_list(value) Convert the value into a list.
do_lower(s) Convert a value to lowercase.
do_mark_safe(value) Mark the value as safe which means that in an environment with automatic
do_mark_unsafe(value) Mark a value as unsafe.
do_pprint(value[, verbose]) Pretty print a variable.
do_random(environment, seq) Return a random item from the sequence.
do_replace(eval_ctx, s, old, new[, count]) Return a copy of the value with all occurrences of a substring replaced with a new one.
do_reverse(value) Reverse the object or return an iterator the iterates over it the other
do_round(value[, precision, method]) Round the number to a given precision.
do_slice(value, slices[, fill_with]) Slice an iterator and return a list of lists containing those items.
do_sort(environment, value[, reverse, ...]) Sort an iterable.
do_striptags(value) Strip SGML/XML tags and replace adjacent whitespace by one space.
do_sum(environment, iterable[, attribute, start]) Returns the sum of a sequence of numbers plus the value of parameter ‘start’ (which defaults to 0).
do_title(s) Return a titlecased version of the value.
do_trim(value) Strip leading and trailing whitespace.
do_truncate(s[, length, killwords, end]) Return a truncated copy of the string.
do_upper(s) Convert a value to uppercase.
do_urlize(eval_ctx, value[, trim_url_limit, ...]) Converts URLs in plain text into clickable links.
do_wordcount(s) Count the words in that string.
do_wordwrap(environment, s[, width, ...]) Return a copy of the string passed to the filter wrapped after 79 characters.
do_xmlattr(_eval_ctx, d[, autospace]) Create an SGML/XML attribute string based on the items in a dict.
environmentfilter(f) Decorator for marking evironment dependent filters.
evalcontextfilter(f) Decorator for marking eval-context dependent filters.
make_attrgetter(environment, attribute) Returns a callable that looks up the given attribute from a passed object with the rules of the environment.

Defined

  • FILTERS
  • Markup
  • Undefined
  • choice
  • escape
  • groupby
  • imap
  • itemgetter
  • math
  • pformat
  • re
  • soft_unicode
  • urlize

Table Of Contents

Previous topic

next

Next topic

FilterArgumentError