How to output mustache templates in a twig template?

只愿长相守 提交于 2019-12-21 20:27:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!