App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Functions | Variables
google.appengine._internal.django.template.defaultfilters Namespace Reference

Functions

def stringfilter
 STRING DECORATOR #. More...
 
def addslashes
 STRINGS #. More...
 
def capfirst
 
def escapejs
 
def fix_ampersands
 
def floatformat
 
def iriencode
 
def linenumbers
 
def lower
 
def make_list
 
def slugify
 
def stringformat
 
def title
 
def truncatewords
 
def truncatewords_html
 
def upper
 
def urlencode
 
def urlize
 
def urlizetrunc
 
def wordcount
 
def wordwrap
 
def ljust
 
def rjust
 
def center
 
def cut
 
def escape
 HTML STRINGS #. More...
 
def force_escape
 
def linebreaks
 
def linebreaksbr
 
def safe
 
def safeseq
 
def removetags
 
def striptags
 
def dictsort
 LISTS #. More...
 
def dictsortreversed
 
def first
 
def join
 
def last
 
def length
 
def length_is
 
def random
 
def slice_
 
def unordered_list
 
def add
 INTEGERS #. More...
 
def get_digit
 
def date
 DATES #. More...
 
def time
 
def timesince
 
def timeuntil
 
def default
 LOGIC #. More...
 
def default_if_none
 
def divisibleby
 
def yesno
 
def filesizeformat
 MISC #. More...
 
def pluralize
 
def phone2numeric
 
def pprint
 

Variables

tuple register = Library()
 
tuple addslashes = stringfilter(addslashes)
 
tuple capfirst = stringfilter(capfirst)
 
tuple escapejs = stringfilter(escapejs)
 
tuple fix_ampersands = stringfilter(fix_ampersands)
 
int pos_inf = 1
 
int neg_inf = -1
 
tuple nan = (1e200 * 1e200)
 
list special_floats = [str(pos_inf), str(neg_inf), str(nan)]
 
tuple iriencode = stringfilter(iriencode)
 
tuple linenumbers = stringfilter(linenumbers)
 
tuple lower = stringfilter(lower)
 
tuple make_list = stringfilter(make_list)
 
tuple slugify = stringfilter(slugify)
 
tuple title = stringfilter(title)
 
tuple truncatewords = stringfilter(truncatewords)
 
tuple truncatewords_html = stringfilter(truncatewords_html)
 
tuple upper = stringfilter(upper)
 
tuple urlencode = stringfilter(urlencode)
 
tuple urlize = stringfilter(urlize)
 
tuple urlizetrunc = stringfilter(urlizetrunc)
 
tuple wordcount = stringfilter(wordcount)
 
tuple wordwrap = stringfilter(wordwrap)
 
tuple ljust = stringfilter(ljust)
 
tuple rjust = stringfilter(rjust)
 
tuple center = stringfilter(center)
 
tuple cut = stringfilter(cut)
 
tuple escape = stringfilter(escape)
 
tuple force_escape = stringfilter(force_escape)
 
tuple linebreaks = stringfilter(linebreaks)
 
tuple linebreaksbr = stringfilter(linebreaksbr)
 
tuple safe = stringfilter(safe)
 
tuple removetags = stringfilter(removetags)
 
tuple striptags = stringfilter(striptags)
 

Detailed Description

Default variable filters.

Function Documentation

def google.appengine._internal.django.template.defaultfilters.add (   value,
  arg 
)

INTEGERS #.

Adds the arg to the value.
def google.appengine._internal.django.template.defaultfilters.addslashes (   value)

STRINGS #.

Adds slashes before quotes. Useful for escaping strings in CSV, for
example. Less useful for escaping JavaScript; use the ``escapejs``
filter instead.
def google.appengine._internal.django.template.defaultfilters.capfirst (   value)
Capitalizes the first character of the value.
def google.appengine._internal.django.template.defaultfilters.center (   value,
  arg 
)
Centers the value in a field of a given width.
def google.appengine._internal.django.template.defaultfilters.cut (   value,
  arg 
)
Removes all values of arg from the given string.
def google.appengine._internal.django.template.defaultfilters.date (   value,
  arg = None 
)

DATES #.

Formats a date according to the given format.
def google.appengine._internal.django.template.defaultfilters.default (   value,
  arg 
)

LOGIC #.

If value is unavailable, use given default.
def google.appengine._internal.django.template.defaultfilters.default_if_none (   value,
  arg 
)
If value is None, use given default.
def google.appengine._internal.django.template.defaultfilters.dictsort (   value,
  arg 
)

LISTS #.

Takes a list of dicts, returns that list sorted by the property given in
the argument.
def google.appengine._internal.django.template.defaultfilters.dictsortreversed (   value,
  arg 
)
Takes a list of dicts, returns that list sorted in reverse order by the
property given in the argument.
def google.appengine._internal.django.template.defaultfilters.divisibleby (   value,
  arg 
)
Returns True if the value is devisible by the argument.
def google.appengine._internal.django.template.defaultfilters.escape (   value)

HTML STRINGS #.

Marks the value as a string that should not be auto-escaped.
def google.appengine._internal.django.template.defaultfilters.escapejs (   value)
Hex encodes characters for use in JavaScript strings.
def google.appengine._internal.django.template.defaultfilters.filesizeformat (   bytes)

MISC #.

Formats the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB,
102 bytes, etc).
def google.appengine._internal.django.template.defaultfilters.first (   value)
Returns the first item in a list.
def google.appengine._internal.django.template.defaultfilters.fix_ampersands (   value)
Replaces ampersands with ``&`` entities.
def google.appengine._internal.django.template.defaultfilters.floatformat (   text,
  arg = -1 
)
Displays a float to a specified number of decimal places.

If called without an argument, it displays the floating point number with
one decimal place -- but only if there's a decimal place to be displayed:

* num1 = 34.23234
* num2 = 34.00000
* num3 = 34.26000
* {{ num1|floatformat }} displays "34.2"
* {{ num2|floatformat }} displays "34"
* {{ num3|floatformat }} displays "34.3"

If arg is positive, it will always display exactly arg number of decimal
places:

* {{ num1|floatformat:3 }} displays "34.232"
* {{ num2|floatformat:3 }} displays "34.000"
* {{ num3|floatformat:3 }} displays "34.260"

If arg is negative, it will display arg number of decimal places -- but
only if there are places to be displayed:

* {{ num1|floatformat:"-3" }} displays "34.232"
* {{ num2|floatformat:"-3" }} displays "34"
* {{ num3|floatformat:"-3" }} displays "34.260"

If the input float is infinity or NaN, the (platform-dependent) string
representation of that value will be displayed.
def google.appengine._internal.django.template.defaultfilters.force_escape (   value)
Escapes a string's HTML. This returns a new string containing the escaped
characters (as opposed to "escape", which marks the content for later
possible escaping).
def google.appengine._internal.django.template.defaultfilters.get_digit (   value,
  arg 
)
Given a whole number, returns the requested digit of it, where 1 is the
right-most digit, 2 is the second-right-most digit, etc. Returns the
original value for invalid input (if input or argument is not an integer,
or if argument is less than 1). Otherwise, output is always an integer.
def google.appengine._internal.django.template.defaultfilters.iriencode (   value)
Escapes an IRI value for use in a URL.
def google.appengine._internal.django.template.defaultfilters.join (   value,
  arg,
  autoescape = None 
)
Joins a list with a string, like Python's ``str.join(list)``.
def google.appengine._internal.django.template.defaultfilters.length (   value)
Returns the length of the value - useful for lists.
def google.appengine._internal.django.template.defaultfilters.length_is (   value,
  arg 
)
Returns a boolean of whether the value's length is the argument.
def google.appengine._internal.django.template.defaultfilters.linebreaks (   value,
  autoescape = None 
)
Replaces line breaks in plain text with appropriate HTML; a single
newline becomes an HTML line break (``<br />``) and a new line
followed by a blank line becomes a paragraph break (``</p>``).
def google.appengine._internal.django.template.defaultfilters.linebreaksbr (   value,
  autoescape = None 
)
Converts all newlines in a piece of plain text to HTML line breaks
(``<br />``).
def google.appengine._internal.django.template.defaultfilters.linenumbers (   value,
  autoescape = None 
)
Displays text with line numbers.
def google.appengine._internal.django.template.defaultfilters.ljust (   value,
  arg 
)
Left-aligns the value in a field of a given width.

Argument: field size.
def google.appengine._internal.django.template.defaultfilters.lower (   value)
Converts a string into all lowercase.
def google.appengine._internal.django.template.defaultfilters.make_list (   value)
Returns the value turned into a list.

For an integer, it's a list of digits.
For a string, it's a list of characters.
def google.appengine._internal.django.template.defaultfilters.phone2numeric (   value)
Takes a phone number and converts it in to its numerical equivalent.
def google.appengine._internal.django.template.defaultfilters.pluralize (   value,
  arg = u's' 
)
Returns a plural suffix if the value is not 1. By default, 's' is used as
the suffix:

* If value is 0, vote{{ value|pluralize }} displays "0 votes".
* If value is 1, vote{{ value|pluralize }} displays "1 vote".
* If value is 2, vote{{ value|pluralize }} displays "2 votes".

If an argument is provided, that string is used instead:

* If value is 0, class{{ value|pluralize:"es" }} displays "0 classes".
* If value is 1, class{{ value|pluralize:"es" }} displays "1 class".
* If value is 2, class{{ value|pluralize:"es" }} displays "2 classes".

If the provided argument contains a comma, the text before the comma is
used for the singular case and the text after the comma is used for the
plural case:

* If value is 0, cand{{ value|pluralize:"y,ies" }} displays "0 candies".
* If value is 1, cand{{ value|pluralize:"y,ies" }} displays "1 candy".
* If value is 2, cand{{ value|pluralize:"y,ies" }} displays "2 candies".
def google.appengine._internal.django.template.defaultfilters.pprint (   value)
A wrapper around pprint.pprint -- for debugging, really.
def google.appengine._internal.django.template.defaultfilters.random (   value)
Returns a random item from the list.
def google.appengine._internal.django.template.defaultfilters.removetags (   value,
  tags 
)
Removes a space separated list of [X]HTML tags from the output.
def google.appengine._internal.django.template.defaultfilters.rjust (   value,
  arg 
)
Right-aligns the value in a field of a given width.

Argument: field size.
def google.appengine._internal.django.template.defaultfilters.safe (   value)
Marks the value as a string that should not be auto-escaped.
def google.appengine._internal.django.template.defaultfilters.safeseq (   value)
A "safe" filter for sequences. Marks each element in the sequence,
individually, as safe, after converting them to unicode. Returns a list
with the results.
def google.appengine._internal.django.template.defaultfilters.slice_ (   value,
  arg 
)
Returns a slice of the list.

Uses the same syntax as Python's list slicing; see
http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice
for an introduction.
def google.appengine._internal.django.template.defaultfilters.slugify (   value)
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
def google.appengine._internal.django.template.defaultfilters.stringfilter (   func)

STRING DECORATOR #.

Decorator for filters which should only receive unicode objects. The object
passed as the first positional argument will be converted to a unicode
object.
def google.appengine._internal.django.template.defaultfilters.stringformat (   value,
  arg 
)
Formats the variable according to the arg, a string formatting specifier.

This specifier uses Python string formating syntax, with the exception that
the leading "%" is dropped.

See http://docs.python.org/lib/typesseq-strings.html for documentation
of Python string formatting
def google.appengine._internal.django.template.defaultfilters.striptags (   value)
Strips all [X]HTML tags.
def google.appengine._internal.django.template.defaultfilters.time (   value,
  arg = None 
)
Formats a time according to the given format.
def google.appengine._internal.django.template.defaultfilters.timesince (   value,
  arg = None 
)
Formats a date as the time since that date (i.e. "4 days, 6 hours").
def google.appengine._internal.django.template.defaultfilters.timeuntil (   value,
  arg = None 
)
Formats a date as the time until that date (i.e. "4 days, 6 hours").
def google.appengine._internal.django.template.defaultfilters.title (   value)
Converts a string into titlecase.
def google.appengine._internal.django.template.defaultfilters.truncatewords (   value,
  arg 
)
Truncates a string after a certain number of words.

Argument: Number of words to truncate after.

Newlines within the string are removed.
def google.appengine._internal.django.template.defaultfilters.truncatewords_html (   value,
  arg 
)
Truncates HTML after a certain number of words.

Argument: Number of words to truncate after.

Newlines in the HTML are preserved.
def google.appengine._internal.django.template.defaultfilters.unordered_list (   value,
  autoescape = None 
)
Recursively takes a self-nested list and returns an HTML unordered list --
WITHOUT opening and closing <ul> tags.

The list is assumed to be in the proper format. For example, if ``var``
contains: ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``,
then ``{{ var|unordered_list }}`` would return::

    <li>States
    <ul>
            <li>Kansas
            <ul>
                    <li>Lawrence</li>
                    <li>Topeka</li>
            </ul>
            </li>
            <li>Illinois</li>
    </ul>
    </li>
def google.appengine._internal.django.template.defaultfilters.upper (   value)
Converts a string into all uppercase.
def google.appengine._internal.django.template.defaultfilters.urlencode (   value)
Escapes a value for use in a URL.
def google.appengine._internal.django.template.defaultfilters.urlize (   value,
  autoescape = None 
)
Converts URLs in plain text into clickable links.
def google.appengine._internal.django.template.defaultfilters.urlizetrunc (   value,
  limit,
  autoescape = None 
)
Converts URLs into clickable links, truncating URLs to the given character
limit, and adding 'rel=nofollow' attribute to discourage spamming.

Argument: Length to truncate URLs to.
def google.appengine._internal.django.template.defaultfilters.wordcount (   value)
Returns the number of words.
def google.appengine._internal.django.template.defaultfilters.wordwrap (   value,
  arg 
)
Wraps words at specified line length.

Argument: number of characters to wrap the text at.
def google.appengine._internal.django.template.defaultfilters.yesno (   value,
  arg = None 
)
Given a string mapping values for true, false and (optionally) None,
returns one of those strings accoding to the value:

==========  ======================  ==================================
Value       Argument                Outputs
==========  ======================  ==================================
``True``    ``"yeah,no,maybe"``     ``yeah``
``False``   ``"yeah,no,maybe"``     ``no``
``None``    ``"yeah,no,maybe"``     ``maybe``
``None``    ``"yeah,no"``           ``"no"`` (converts None to False
                                    if no mapping for None is given.
==========  ======================  ==================================