Alex Rivera | Logout

How to escape Twig delimiters in a Twig template?

Asked 2012-09-19T14:44:16.823
52

Twig uses the {{ }}, {% %}, {# #} delimiters.

But how can I display {{ }} in a Twig template? I'm not talking about HTML escaping.

I ask the question as I want to include a mustache template in my Twig template so that I will fill with data coming from an AJAX call.

Edit
Report

1 Answer

16

The Twig documentation gives two suggestions. The first is simply to output a string:

{{ '{{' }}

Otherwise, if you want to output a long section (it sounds like you do) you can use the raw tag:

{% raw %}
    your mustache content here
{% endraw %}
answered 2012-09-19T14:48:29.397

Your Answer