Skip to content

Commit

Permalink
added some more tests for the filename autoescape strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 14, 2015
1 parent 4481bf5 commit 01ab6f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
18 changes: 11 additions & 7 deletions doc/api.rst
Expand Up @@ -94,15 +94,19 @@ The following options are available:
replace them with a ``null`` value. When set to ``true``, Twig throws an
exception instead (default to ``false``).

* ``autoescape``: If set to ``true``, auto-escaping will be enabled by default
for all templates (default to ``true``). As of Twig 1.8, you can set the
escaping strategy to use (``html``, ``js``, ``false`` to disable). As of Twig
1.9, you can set the escaping strategy to use (``css``, ``url``,
* ``autoescape``: If set to ``true``, HTML auto-escaping will be enabled by
default for all templates (default to ``true``).

As of Twig 1.8, you can set the escaping strategy to use (``html``, ``js``,
``false`` to disable).

As of Twig 1.9, you can set the escaping strategy to use (``css``, ``url``,
``html_attr``, or a PHP callback that takes the template "filename" and must
return the escaping strategy to use -- the callback cannot be a function name
to avoid collision with built-in escaping strategies). As of Twig 1.17, the
``filename`` escaping strategy determines the escaping strategy to use for a
template based on the template filename extension.
to avoid collision with built-in escaping strategies).

As of Twig 1.17, the ``filename`` escaping strategy determines the escaping
strategy to use for a template based on the template filename extension.

* ``optimizations``: A flag that indicates which optimizations to apply
(default to ``-1`` -- all optimizations are enabled; set it to ``0`` to
Expand Down
18 changes: 18 additions & 0 deletions test/Twig/Tests/Fixtures/autoescape/filename.test
@@ -0,0 +1,18 @@
--TEST--
"filename" autoescape strategy
--TEMPLATE--
{{ br -}}
{{ include('index.html.twig') -}}
{{ include('index.txt.twig') -}}
--TEMPLATE(index.html.twig)--
{{ br -}}
--TEMPLATE(index.txt.twig)--
{{ br -}}
--DATA--
return array('br' => '<br />')
--CONFIG--
return array('autoescape' => 'filename')
--EXPECT--
&lt;br /&gt;
&lt;br /&gt;
<br />

0 comments on commit 01ab6f3

Please sign in to comment.