From 01ab6f317b1bd2bbe00a67fe77807bccb3962eda Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 14 Jan 2015 07:56:45 +0100 Subject: [PATCH] added some more tests for the filename autoescape strategy --- doc/api.rst | 18 +++++++++++------- .../Tests/Fixtures/autoescape/filename.test | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 test/Twig/Tests/Fixtures/autoescape/filename.test diff --git a/doc/api.rst b/doc/api.rst index f6619473c5..937f6b8009 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -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 diff --git a/test/Twig/Tests/Fixtures/autoescape/filename.test b/test/Twig/Tests/Fixtures/autoescape/filename.test new file mode 100644 index 0000000000..b091ad34d3 --- /dev/null +++ b/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' => '
') +--CONFIG-- +return array('autoescape' => 'filename') +--EXPECT-- +<br /> +<br /> +