added some more tests for the filename autoescape strategy

This commit is contained in:
Fabien Potencier
2015-01-14 07:56:45 +01:00
parent 4481bf5f38
commit 01ab6f317b
2 changed files with 29 additions and 7 deletions
+11 -7
View File
@@ -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
@@ -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 />