Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

symfony - Twig: prevent parsing of client-side templates

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>

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?

question from:https://stackoverflow.com/questions/9443313/twig-prevent-parsing-of-client-side-templates

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is raw tag for this purpose:

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

Update

As raw tag is deprecated use verbatim instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...