forked from twigphp/Twig
-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged branch fabpot/verbatim (PR twigphp#947)
This PR was merged into the master branch. Commits ------- cd4ab0f renamed the raw tag to verbatim to avoid confusion with the raw filter Discussion ---------- renamed the raw tag to verbatim to avoid confusion with the raw filter In Twig, we have a `raw` tag and a raw filter. Unfortunately, they are totally unrelated and that is confusing. I propose to rename the `raw` tag to `verbatim`. Of course, for BC reasons, the old `raw` tag will be kept around for the foreseeable future as an alias to `verbatim`. For the record, `raw` is used by Jinja (http://jinja.pocoo.org/docs/templates/#escaping), whereas `verbatim` was introduced in Django in 1.5 (https://docs.djangoproject.com/en/dev/releases/1.5/#verbatim-template-tag).
- Loading branch information
Showing
9 changed files
with
97 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ Tags | |
use | ||
spaceless | ||
autoescape | ||
raw | ||
verbatim | ||
flush | ||
do | ||
sandbox | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--TEST-- | ||
"verbatim" tag | ||
--TEMPLATE-- | ||
{% verbatim %} | ||
{{ foo }} | ||
{% endverbatim %} | ||
--DATA-- | ||
return array() | ||
--EXPECT-- | ||
{{ foo }} |
56 changes: 56 additions & 0 deletions
56
test/Twig/Tests/Fixtures/tags/verbatim/whitespace_control.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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*** |