From: Fabien Potencier Date: Wed, 25 Apr 2012 05:35:12 +0000 (+0200) Subject: tweaked doc for the escape filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d458e8c8920d6e646f59c762cd4d401a80735423;p=web%2Fkonrad%2Ftwig.git tweaked doc for the escape filter --- diff --git a/doc/filters/escape.rst b/doc/filters/escape.rst index dd927b4..5142977 100644 --- a/doc/filters/escape.rst +++ b/doc/filters/escape.rst @@ -15,8 +15,16 @@ For convenience, the ``e`` filter is defined as an alias: {{ user.username|e }} -The ``escape`` filter can also be used in another context than HTML; for -instance, to escape variables included in a JavaScript: +The ``escape`` filter can also be used in other contexts than HTML thanks to +an optional argument which defines the escaping strategy to use: + +.. code-block:: jinja + + {{ user.username|e }} + {# is equivalent to #} + {{ user.username|e('html') }} + +And here is how to escape variables included in JavaScript code: .. code-block:: jinja @@ -25,6 +33,7 @@ instance, to escape variables included in a JavaScript: .. note:: - Internally, ``escape`` uses the PHP native `htmlspecialchars`_ function. + Internally, ``escape`` uses the PHP native `htmlspecialchars`_ function + for the HTML escaping strategy. .. _`htmlspecialchars`: http://php.net/htmlspecialchars