Twig:防止解析客户端模板 [英] Twig: prevent parsing of client-side templates

查看:26
本文介绍了Twig:防止解析客户端模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要输出客户端车把模板的一部分,其中的标签类似于 twig 的say"标签:

I need to output a portion of client-side handlebars templates, which has tags similar to twig's 'say' tags:

  <script type="text/x-handlebars">
    {{#view App.MyView}}
      <h1>Hello world!</h1>
    {{/view}}
  </script>

并且 twig 尝试解析这些模板.我该如何预防?是否可以将模板的一部分标记为纯文本?

And twig attempts to parse these templates. How do I prevent it? Is it possible to mark a section of a template as plain text?

推荐答案

raw 标签:

<script type="text/x-handlebars">
  {% raw %}
    {{#view App.MyView}}
      <h1>Hello world!</h1>
    {{/view}}
  {% endraw %}
</script>

更新

由于 raw 标签已被弃用,请使用 verbatim 代替.

Update

As raw tag is deprecated use verbatim instead.

这篇关于Twig:防止解析客户端模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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