如何在Twig模板中使用Moustache?它们都有相同的标签定界符 [英] How to use Mustache in Twig templates? They both have the same tag delimiters

查看:68
本文介绍了如何在Twig模板中使用Moustache?它们都有相同的标签定界符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用Twig.它使用以下标记:{{ name }}

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

我也想在我的项目中加入Moustache.但是Mustache也使用相同的标签{{ 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.

Mustache在其文档中提供的解决方案当然行不通.因为我必须在Twig模板中键入Twig分隔符{{才能更改Moustache分隔符.

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 }} 

如何通过?还有其他方法可以在设置中的某处更改Moustache分隔符吗?

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

推荐答案

如果您有大型模板可以通过树枝.更好的解决方案是暂时关闭自动转义.

If you have a large template to pass through twig. A better solution is to temporarily turn off autoescape.

{% verbatim %}
    Everything will be outputted as is in this block
{% endverbatim %}

这篇关于如何在Twig模板中使用Moustache?它们都有相同的标签定界符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆