mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
renamed the raw tag to verbatim to avoid confusion with the raw filter
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.12.0 (2012-XX-XX)
|
||||
|
||||
* renamed the raw tag to verbatim to avoid confusion with the raw filter (the raw tag still works though)
|
||||
* fixed registration of tests and functions as anonymous functions
|
||||
* fixed global management
|
||||
|
||||
|
||||
+1
-1
@@ -351,7 +351,7 @@ The ``core`` extension defines all the core features of Twig:
|
||||
* ``do``
|
||||
* ``embed``
|
||||
* ``flush``
|
||||
* ``raw``
|
||||
* ``verbatim``
|
||||
* ``sandbox``
|
||||
* ``use``
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ Tags
|
||||
use
|
||||
spaceless
|
||||
autoescape
|
||||
raw
|
||||
verbatim
|
||||
flush
|
||||
do
|
||||
sandbox
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
``raw``
|
||||
=======
|
||||
|
||||
The ``raw`` tag marks sections as being raw text that should not be parsed.
|
||||
For example to put Twig syntax as example into a template you can use this
|
||||
snippet:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{% raw %}
|
||||
<ul>
|
||||
{% for item in seq %}
|
||||
<li>{{ item }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endraw %}
|
||||
@@ -0,0 +1,24 @@
|
||||
``verbatim``
|
||||
============
|
||||
|
||||
.. versionadded:: 1.12
|
||||
The ``verbatim`` tag was added in Twig 1.12 (it was named ``raw`` before).
|
||||
|
||||
The ``verbatim`` tag marks sections as being raw text that should not be
|
||||
parsed. For example to put Twig syntax as example into a template you can use
|
||||
this snippet:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{% verbatim %}
|
||||
<ul>
|
||||
{% for item in seq %}
|
||||
<li>{{ item }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endverbatim %}
|
||||
|
||||
.. note::
|
||||
|
||||
The ``verbatim`` tag works in the exact same way as the old ``raw`` tag,
|
||||
but was renamed to avoid confusion with the ``raw`` filter.
|
||||
+2
-1
@@ -489,7 +489,8 @@ expression:
|
||||
|
||||
{{ '{{' }}
|
||||
|
||||
For bigger sections it makes sense to mark a block :doc:`raw<tags/raw>`.
|
||||
For bigger sections it makes sense to mark a block
|
||||
:doc:`verbatim<tags/verbatim>`.
|
||||
|
||||
Macros
|
||||
------
|
||||
|
||||
+2
-2
@@ -61,10 +61,10 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
$this->regexes = array(
|
||||
'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
|
||||
'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
|
||||
'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*endraw\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
|
||||
'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:endraw|endverbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
|
||||
'operator' => $this->getOperatorRegex(),
|
||||
'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s',
|
||||
'lex_block_raw' => '/\s*raw\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As',
|
||||
'lex_block_raw' => '/\s*(?:raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As',
|
||||
'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As',
|
||||
'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
|
||||
'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
"verbatim" tag
|
||||
--TEMPLATE--
|
||||
{% verbatim %}
|
||||
{{ foo }}
|
||||
{% endverbatim %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
{{ foo }}
|
||||
@@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
"verbatim" tag
|
||||
--TEMPLATE--
|
||||
1***
|
||||
|
||||
{%- verbatim %}
|
||||
{{ 'bla' }}
|
||||
{% endverbatim %}
|
||||
|
||||
1***
|
||||
2***
|
||||
|
||||
{%- verbatim -%}
|
||||
{{ 'bla' }}
|
||||
{% endverbatim %}
|
||||
|
||||
2***
|
||||
3***
|
||||
|
||||
{%- verbatim -%}
|
||||
{{ 'bla' }}
|
||||
{% endverbatim -%}
|
||||
|
||||
3***
|
||||
4***
|
||||
|
||||
{%- verbatim -%}
|
||||
{{ 'bla' }}
|
||||
{%- endverbatim %}
|
||||
|
||||
4***
|
||||
5***
|
||||
|
||||
{%- verbatim -%}
|
||||
{{ 'bla' }}
|
||||
{%- endverbatim -%}
|
||||
|
||||
5***
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
1***
|
||||
{{ 'bla' }}
|
||||
|
||||
|
||||
1***
|
||||
2***{{ 'bla' }}
|
||||
|
||||
|
||||
2***
|
||||
3***{{ 'bla' }}
|
||||
3***
|
||||
4***{{ 'bla' }}
|
||||
|
||||
4***
|
||||
5***{{ 'bla' }}5***
|
||||
Reference in New Issue
Block a user