Mustache.js: 如何在 Twig 模板中使用 Mustache? 它们都具有相同的标记分隔符

创建于 2015-04-08  ·  2评论  ·  资料来源: janl/mustache.js

我在我的项目中使用 Twig。 它使用这些标签: {{ name }}

我也想在我的项目中包含 Mustache。 但是 Mustache 也使用相同的标签{{ name }} ,因此存在冲突并且没有任何效果。

Mustache 在他们的文档中提供的解决方案当然不起作用。 因为我必须在我的 Twig 模板中输入 Twig 分隔符{{才能更改 Mustache 分隔符。

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

如何通过它? 有没有其他方法可以在设置中的某个地方更改 Mustache 分隔符?

Stackoverflow 上的问题http://stackoverflow.com/questions/29509827/how-to-use-mustache-in-twig-templates-they-both-have-the-same-tag-delimites

最有用的评论

您还可以使用 Twig 的verbatim标签来防止它碰到 Mustache 的更改分隔符标签:

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

所有2条评论

您可以以编程方式更改分隔符。 https://github.com/janl/mustache.js/blob/master/mustache.js#L552

您还可以使用 Twig 的verbatim标签来防止它碰到 Mustache 的更改分隔符标签:

{% verbatim %}
{{=<% %>=}}
{% endverbatim %}
此页面是否有帮助?
0 / 5 - 0 等级

相关问题

funston picture funston  ·  7评论

Immortalin picture Immortalin  ·  12评论

barbalex picture barbalex  ·  5评论

chlab picture chlab  ·  11评论

ForbesLindesay picture ForbesLindesay  ·  14评论