diff --git a/CHANGELOG b/CHANGELOG
index a397469ec..6737cd087 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@ Backward incompatibilities:
* the constant filter has been converted to a function: {{ some_date|date('DATE_W3C'|constant) }} -> {{ some_date|date(constant('DATE_W3C')) }}
* the cycle filter has been converted to a function: {{ ['odd', 'even']|cycle(i) }} -> {{ cycle(['odd', 'even'], i) }}
* the for tag does not support "joined by" anymore
+ * the autoescape first argument is now true/false (instead of on/off)
Changes:
diff --git a/doc/api.rst b/doc/api.rst
index 3abc46c25..4feec5983 100644
--- a/doc/api.rst
+++ b/doc/api.rst
@@ -341,7 +341,7 @@ You can also change the escaping mode locally by using the ``autoescape`` tag:
.. code-block:: jinja
- {% autoescape on %}
+ {% autoescape true %}
{% var %}
{% var|raw %} {# var won't be escaped #}
{% var|escape %} {# var won't be doubled-escaped #}
@@ -401,7 +401,7 @@ Twig 0.9.9 and above):
.. code-block:: jinja
- {% autoescape js on %}
+ {% autoescape true js %}
{{ var|escape('html') }} {# will be escaped for html and javascript #}
{{ var }} {# will be escaped for javascript #}
{{ var|escape('js') }} {# won't be double-escaped #}
diff --git a/doc/templates.rst b/doc/templates.rst
index af173b4c9..5a4457bb4 100644
--- a/doc/templates.rst
+++ b/doc/templates.rst
@@ -427,15 +427,15 @@ template to be escaped or not by using the ``autoescape`` tag:
.. code-block:: jinja
- {% autoescape on %}
+ {% autoescape true %}
Everything will be automatically escaped in this block
{% endautoescape %}
- {% autoescape off %}
+ {% autoescape false %}
Everything will be outputed as is in this block
{% endautoescape %}
- {% autoescape on js %}
+ {% autoescape true js %}
Everything will be automatically escaped in this block
using the js escaping strategy
{% endautoescape %}
@@ -1262,9 +1262,9 @@ the last filter applied to it.
.. code-block:: jinja
- {% autoescape on }
+ {% autoescape true }
{{ var|raw }} {# var won't be escaped #}
- {% autoescape off %}
+ {% endautoescape %}
``merge`` (new in Twig 0.9.10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/Twig/TokenParser/AutoEscape.php b/lib/Twig/TokenParser/AutoEscape.php
index 43bccb016..5146a9504 100644
--- a/lib/Twig/TokenParser/AutoEscape.php
+++ b/lib/Twig/TokenParser/AutoEscape.php
@@ -21,14 +21,14 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
{
$lineno = $token->getLine();
$value = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue();
- if (!in_array($value, array('on', 'off'))) {
- throw new Twig_Error_Syntax("Autoescape value must be 'on' or 'off'", $lineno);
+ if (!in_array($value, array('true', 'false'))) {
+ throw new Twig_Error_Syntax("Autoescape value must be 'true' or 'false'", $lineno);
}
- $value = 'on' === $value ? 'html' : false;
+ $value = 'true' === $value ? 'html' : false;
if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) {
if (false === $value) {
- throw new Twig_Error_Syntax(sprintf('Unexpected escaping strategy as you set autoescaping to off.', $lineno), -1);
+ throw new Twig_Error_Syntax(sprintf('Unexpected escaping strategy as you set autoescaping to false.', $lineno), -1);
}
$value = $this->parser->getStream()->next()->getValue();
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/basic.test b/test/Twig/Tests/Fixtures/tags/autoescape/basic.test
index 6f6c1b975..62d8c3c44 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/basic.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/basic.test
@@ -1,16 +1,16 @@
--TEST--
"autoescape" tag applies escaping on its children
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
{{ var }}
{% endautoescape %}
-{% autoescape off %}
+{% autoescape false %}
{{ var }}
{% endautoescape %}
-{% autoescape on %}
+{% autoescape true %}
{{ var }}
{% endautoescape %}
-{% autoescape off %}
+{% autoescape false %}
{{ var }}
{% endautoescape %}
--DATA--
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test b/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test
index 8e0576178..b48f73eb2 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag applies escaping on embedded blocks
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
{% block foo %}
{{ var }}
{% endblock %}
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test b/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test
index fc7aa8cd8..fd62a84fa 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag does not double-escape
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
{{ var|escape }}
{% endautoescape %}
--DATA--
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/functions.test b/test/Twig/Tests/Fixtures/tags/autoescape/functions.test
index ce62744b2..9a229d053 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/functions.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/functions.test
@@ -2,8 +2,8 @@
"autoescape" tag applies escaping after calling functions
--TEMPLATE--
-autoescape off
-{% autoescape off %}
+autoescape false
+{% autoescape false %}
safe_br
{{ safe_br() }}
@@ -13,8 +13,8 @@ unsafe_br
{% endautoescape %}
-autoescape on
-{% autoescape on %}
+autoescape true
+{% autoescape true %}
safe_br
{{ safe_br() }}
@@ -36,8 +36,8 @@ unsafe_br()|escape
{% endautoescape %}
-autoescape on js
-{% autoescape on js %}
+autoescape true js
+{% autoescape true js %}
safe_br
{{ safe_br() }}
@@ -47,7 +47,7 @@ safe_br
return array()
--EXPECT--
-autoescape off
+autoescape false
safe_br
@@ -56,7 +56,7 @@ unsafe_br
-autoescape on
+autoescape true
safe_br
@@ -77,7 +77,7 @@ unsafe_br()|escape
<br />
-autoescape on js
+autoescape true js
safe_br
\x3cbr \x2f\x3e
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/literal.test b/test/Twig/Tests/Fixtures/tags/autoescape/literal.test
index eb0a987fa..4c92d0820 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/literal.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/literal.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag does not apply escaping on literals
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
1. Simple literal
{{ "
" }}
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/nested.test b/test/Twig/Tests/Fixtures/tags/autoescape/nested.test
index 49f4da9ad..c9112117b 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/nested.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/nested.test
@@ -2,11 +2,11 @@
"autoescape" tags can be nested at will
--TEMPLATE--
{{ var }}
-{% autoescape on %}
+{% autoescape true %}
{{ var }}
- {% autoescape off %}
+ {% autoescape false %}
{{ var }}
- {% autoescape on %}
+ {% autoescape true %}
{{ var }}
{% endautoescape %}
{{ var }}
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/objects.test b/test/Twig/Tests/Fixtures/tags/autoescape/objects.test
index 12964a6f0..f6c03ed4e 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/objects.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/objects.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag applies escaping to object method calls
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
{{ user.name }}
{{ user.name|lower }}
{{ user }}
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test b/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test
index a2c9e40df..9ea4fd4dc 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test
@@ -1,9 +1,9 @@
--TEST--
"autoescape" tag accepts an escaping strategy
--TEMPLATE--
-{% autoescape on js %}{{ var }}{% endautoescape %}
+{% autoescape true js %}{{ var }}{% endautoescape %}
-{% autoescape on html %}{{ var }}{% endautoescape %}
+{% autoescape true html %}{{ var }}{% endautoescape %}
--DATA--
return array('var' => '
"')
--EXPECT--
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/type.test b/test/Twig/Tests/Fixtures/tags/autoescape/type.test
index de3f6c3ef..17cec13c7 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/type.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/type.test
@@ -2,39 +2,39 @@
escape types
--TEMPLATE--
-1. autoescape on |escape('js')
+1. autoescape true |escape('js')
-{% autoescape on %}
+{% autoescape true %}
{% endautoescape %}
-2. autoescape on html |escape('js')
+2. autoescape true html |escape('js')
-{% autoescape on html %}
+{% autoescape true html %}
{% endautoescape %}
-3. autoescape on js |escape('js')
+3. autoescape true js |escape('js')
-{% autoescape on js %}
+{% autoescape true js %}
{% endautoescape %}
4. no escape
-{% autoescape off %}
+{% autoescape false %}
{% endautoescape %}
5. |escape('js')|escape('html')
-{% autoescape off %}
+{% autoescape false %}
{% endautoescape %}
-6. autoescape on html |escape('js')|escape('html')
+6. autoescape true html |escape('js')|escape('html')
-{% autoescape on html %}
+{% autoescape true html %}
{% endautoescape %}
@@ -42,15 +42,15 @@ escape types
return array('msg' => "<>\n'\"")
--EXPECT--
-1. autoescape on |escape('js')
+1. autoescape true |escape('js')
-2. autoescape on html |escape('js')
+2. autoescape true html |escape('js')
-3. autoescape on js |escape('js')
+3. autoescape true js |escape('js')
@@ -63,7 +63,7 @@ return array('msg' => "<>\n'\"")
-6. autoescape on html |escape('js')|escape('html')
+6. autoescape true html |escape('js')|escape('html')
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test
index 53892b17a..d795b8285 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag applies escaping after calling filters
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
(escape_and_nl2br is an escaper filter)
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test
index 9cf12a14a..0ff1ad3e6 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag do not applies escaping on filter arguments
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
{{ var|nl2br("
") }}
{{ var|nl2br("
"|escape) }}
{{ var|nl2br(sep) }}
diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test b/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test
index a60f7c963..44d42e7a3 100644
--- a/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test
+++ b/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag applies escaping after calling filters, and before calling pre_escape filters
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
(nl2br is pre_escaped for "html" and declared safe for "html")
diff --git a/test/Twig/Tests/Fixtures/tags/raw.test b/test/Twig/Tests/Fixtures/tags/raw.test
index ea19b5e29..86e55fddb 100644
--- a/test/Twig/Tests/Fixtures/tags/raw.test
+++ b/test/Twig/Tests/Fixtures/tags/raw.test
@@ -1,7 +1,7 @@
--TEST--
"autoescape" tag does not escape when raw is used as a filter
--TEMPLATE--
-{% autoescape on %}
+{% autoescape true %}
{{ var|raw }}
{% endautoescape %}
--DATA--