Mustache.js: How to use Mustache in Twig templates? They both have the same tag delimites

Created on 8 Apr 2015  ·  2Comments  ·  Source: janl/mustache.js

I use Twig in my project. It uses these tags: {{ name }}

I want to include Mustache in my project as well. But Mustache also uses the same tags {{ name }}, so there is a conflict and nothing works.

The solution Mustache provides in their docs of course doesn't work. Because I have to type Twig delimiter {{ in my Twig template to change Mustache delimiter.

* {{ default_tags }}
{{=<% %>=}}
* <% erb_style_tags %>
<%={{ }}=%>
* {{ default_tags_again }} 

How to pass over it? Is there any other way to change Mustache delimiters once somewhere in settings?

The question on Stackoverflow http://stackoverflow.com/questions/29509827/how-to-use-mustache-in-twig-templates-they-both-have-the-same-tag-delimites

Most helpful comment

You can also use Twig's verbatim tag to keep it from hitting Mustache's change delimiter tag:

{% verbatim %}
{{=<% %>=}}
{% endverbatim %}

All 2 comments

You can change the delimiters programatically. https://github.com/janl/mustache.js/blob/master/mustache.js#L552

You can also use Twig's verbatim tag to keep it from hitting Mustache's change delimiter tag:

{% verbatim %}
{{=<% %>=}}
{% endverbatim %}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

amper5and picture amper5and  ·  5Comments

connor11528 picture connor11528  ·  3Comments

mbrodala picture mbrodala  ·  16Comments

ForbesLindesay picture ForbesLindesay  ·  14Comments

zekth picture zekth  ·  18Comments