I need to output a portion of client-side handlebars templates, which has tags similar to twig's 'say' tags:
<script type="text/x-handlebars"> {{#view App.MyView}} <h1>Hello world!</h1> {{/view}} </script>
And twig attempts to parse these templates. How do I prevent it? Is it possible to mark a section of a template as plain text?
It is sometimes desirable or even necessary to have Twig ignore parts it would otherwise handle as variables or blocks. For example if the default syntax is used and you want to use { { as raw string in the template and not start a variable you have to use a trick.
Netbeans via the Twig syntax plugin (until 7.1, native as of 7.2) PhpStorm (native as of 2.1) Also, TwigFiddle is an online service that allows you to execute Twig templates from a browser; it supports all versions of Twig. The application passes variables to the templates for manipulation in the template.
The result of evaluating that expression is inserted into the string: Tag level line whitespace control was added in Twig 2.8. The first newline after a template tag is removed automatically (like in PHP). Whitespace is not further modified by the template engine, so each whitespace (spaces, tabs, newlines etc.) is returned unchanged.
Also, TwigFiddle is an online service that allows you to execute Twig templates from a browser; it supports all versions of Twig. The application passes variables to the templates for manipulation in the template. Variables may have attributes or elements you can access, too.
There is raw tag for this purpose:
<script type="text/x-handlebars"> {% raw %} {{#view App.MyView}} <h1>Hello world!</h1> {{/view}} {% endraw %} </script>
As raw
tag is deprecated use verbatim
instead.
{% raw %} deprecated
{% verbatim %} <ul> {% for item in seq %} <li>{{ item }}</li> {% endfor %} </ul> {% endverbatim %}
Source: http://twig.sensiolabs.org/doc/tags/verbatim.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With