|
@@ -19,7 +19,7 @@ Built-in tag reference
|
|
|
autoescape
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
-**New in Django development version**
|
|
|
+.. versionadded:: 1.0
|
|
|
|
|
|
Control the current auto-escaping behavior. This tag takes either ``on`` or
|
|
|
``off`` as an argument and that determines whether auto-escaping is in effect
|
|
@@ -54,8 +54,8 @@ Ignore everything between ``{% comment %}`` and ``{% endcomment %}``
|
|
|
cycle
|
|
|
~~~~~
|
|
|
|
|
|
-**Changed in Django development version**
|
|
|
-Cycle among the given strings or variables each time this tag is encountered.
|
|
|
+.. versionchanged:: 1.0
|
|
|
+ Cycle among the given strings or variables each time this tag is encountered.
|
|
|
|
|
|
Within a loop, cycles among the given strings/variables each time through the
|
|
|
loop::
|
|
@@ -171,7 +171,8 @@ provided in ``athlete_list``::
|
|
|
|
|
|
You can loop over a list in reverse by using ``{% for obj in list reversed %}``.
|
|
|
|
|
|
-**New in Django development version**
|
|
|
+.. versionadded:: 1.0
|
|
|
+
|
|
|
If you need to loop over a list of lists, you can unpack the values
|
|
|
in each sub-list into individual variables. For example, if your context
|
|
|
contains a list of (x,y) coordinates called ``points``, you could use the
|
|
@@ -671,9 +672,11 @@ such as this::
|
|
|
|
|
|
The template tag will output the string ``/clients/client/123/``.
|
|
|
|
|
|
-**New in development version:** If you're using :ref:`named URL patterns
|
|
|
-<naming-url-patterns>`, you can refer to the name of the pattern in the ``url``
|
|
|
-tag instead of using the path to the view.
|
|
|
+.. versionadded:: 1.0
|
|
|
+
|
|
|
+If you're using :ref:`named URL patterns <naming-url-patterns>`, you can
|
|
|
+refer to the name of the pattern in the ``url`` tag instead of using the
|
|
|
+path to the view.
|
|
|
|
|
|
Note that if the URL you're reversing doesn't exist, you'll get an
|
|
|
:exc:`NoReverseMatch` exception raised, which will cause your site to display an
|
|
@@ -719,7 +722,7 @@ which is rounded up to 88).
|
|
|
with
|
|
|
~~~~
|
|
|
|
|
|
-**New in Django development version**
|
|
|
+.. versionadded:: 1.0
|
|
|
|
|
|
Caches a complex variable under a simpler name. This is useful when accessing
|
|
|
an "expensive" method (e.g., one that hits the database) multiple times.
|
|
@@ -758,9 +761,6 @@ addslashes
|
|
|
|
|
|
Adds slashes before quotes. Useful for escaping strings in CSV, for example.
|
|
|
|
|
|
-**New in Django development version**: For escaping data in JavaScript strings,
|
|
|
-use the `escapejs`_ filter instead.
|
|
|
-
|
|
|
.. templatefilter:: capfirst
|
|
|
|
|
|
capfirst
|
|
@@ -906,16 +906,17 @@ applied to the result will only result in one round of escaping being done. So
|
|
|
it is safe to use this function even in auto-escaping environments. If you want
|
|
|
multiple escaping passes to be applied, use the ``force_escape`` filter.
|
|
|
|
|
|
-**New in Django development version:** Due to auto-escaping, the behavior of
|
|
|
-this filter has changed slightly. The replacements are only made once, after
|
|
|
-all other filters are applied -- including filters before and after it.
|
|
|
+.. versionchanged:: 1.0
|
|
|
+ Due to auto-escaping, the behavior of this filter has changed slightly.
|
|
|
+ The replacements are only made once, after
|
|
|
+ all other filters are applied -- including filters before and after it.
|
|
|
|
|
|
.. templatefilter:: escapejs
|
|
|
|
|
|
escapejs
|
|
|
~~~~~~~~
|
|
|
|
|
|
-**New in Django development version**
|
|
|
+.. versionadded:: 1.0
|
|
|
|
|
|
Escapes characters for use in JavaScript strings. This does *not* make the
|
|
|
string safe for use in HTML, but does protect you from syntax errors when using
|
|
@@ -953,6 +954,9 @@ If ``value`` is the list ``['a', 'b', 'c']``, the output will be ``'a'``.
|
|
|
fix_ampersands
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
+.. versionchanged:: 1.0
|
|
|
+ This is rarely useful as ampersands are now automatically escaped. See escape_ for more information.
|
|
|
+
|
|
|
Replaces ampersands with ``&`` entities.
|
|
|
|
|
|
For example::
|
|
@@ -961,10 +965,6 @@ For example::
|
|
|
|
|
|
If ``value`` is ``Tom & Jerry``, the output will be ``Tom & Jerry``.
|
|
|
|
|
|
-**New in Django development version**: This filter generally is no longer
|
|
|
-useful, because ampersands are automatically escaped in templates. See escape_
|
|
|
-for more on how auto-escaping works.
|
|
|
-
|
|
|
.. templatefilter:: floatformat
|
|
|
|
|
|
floatformat
|
|
@@ -1012,7 +1012,7 @@ with an argument of ``-1``.
|
|
|
force_escape
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
-**New in Django development version**
|
|
|
+.. versionadded:: 1.0
|
|
|
|
|
|
Applies HTML escaping to a string (see the ``escape`` filter for details).
|
|
|
This filter is applied *immediately* and returns a new, escaped string. This
|
|
@@ -1067,7 +1067,7 @@ If ``value`` is the list ``['a', 'b', 'c']``, the output will be the string
|
|
|
last
|
|
|
~~~~
|
|
|
|
|
|
-**New in Django development version.**
|
|
|
+.. versionadded:: 1.0
|
|
|
|
|
|
Returns the last item in a list.
|
|
|
|
|
@@ -1419,8 +1419,8 @@ unordered_list
|
|
|
Recursively takes a self-nested list and returns an HTML unordered list --
|
|
|
WITHOUT opening and closing <ul> tags.
|
|
|
|
|
|
-**New in Django development version:** The format accepted by
|
|
|
-``unordered_list`` has changed to be easier to understand.
|
|
|
+.. versionchanged:: 1.0
|
|
|
+ The format accepted by ``unordered_list`` has changed to be easier to understand.
|
|
|
|
|
|
The list is assumed to be in the proper format. For example, if ``var`` contains
|
|
|
``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then
|