Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig lexer is missing support for the verbatim tag #982

Closed
stof opened this issue Sep 6, 2018 · 0 comments · Fixed by #1003
Closed

Twig lexer is missing support for the verbatim tag #982

stof opened this issue Sep 6, 2018 · 0 comments · Fixed by #1003

Comments

@stof
Copy link

stof commented Sep 6, 2018

In Twig, anything between a {% verbatim %} tag and its following {% endverbatim %} tag is not parsed as Twig, but is part of the output as is. But the Twig syntax highlighter will still highlight Twig markup inside it.

The definition of this behavior also implies that you cannot nest a verbatim tag into another one:

{{ 'start'|title }}
{% verbatim %}
hello {{ world }}
{# that's not a Twig comment, and next line does not start a verbatim tag but writes such text #}
{% verbatim %} that's just output {% endverbatim %}
{{ 'that\'s actually Twig markup again here' }}
{# that one is a syntax error, as the only actual verbatim tag opened at the start ended above #}
{% endverbatim %}

Note that in Twig 1.x, there was a {% raw %}/{% endraw %} tag with the same behavior (start and end tag had to match), which was deprecated and does not exist anymore in Twig 2.x. I'm not sure whether you want to support it.

pyrmont pushed a commit that referenced this issue Jun 10, 2019
Jinja provides a `raw` tag and Twig provides a `raw` tag in its
1.x version and a `verbatim` one in newer versions. Since the Twig 
lexer extends from the Jinja one, the latter holds the logic for 
both tags. This fixes #982 and fixes #983.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant