问题
I need to add mustache templates to a Twig template using symfony2.
Someone has created a 'verbatim' template tag for django and I'm looking for a corresponding one for twig that will prevent it from parsing the mustache elements.
Can anyone point me in the right direction please?
Thanks
回答1:
I think you are looking for the verbatim tag.
UPDATE for AlainTiemblo :
But what if you need to write {% endverbatim %}
verbatim ?
You must then resort to the least elegant method (you can't use verbatim anymore)
{{'twig code here{% endverbatim %}twig code there' }}
If the twig code is big, do this:
{% verbatim %}
twig code here
{% endverbatim %}
{{ '{% endverbatim %}' }}
{% verbatim %}
twig code there
{% endverbatim %}
回答2:
You can now set directly new tags with Mustache using
Mustache.tags = ["[[","]]"];
for example.
来源:https://stackoverflow.com/questions/10862521/how-to-output-mustache-templates-in-a-twig-template