How do I escape Twig code to prevent it from being processed?
Escape single lines as strings:
{{ '{% set foo = "bar" %}' }}
Use
autoescape
to escape multiple lines, optionally specifying a syntax (see docs):{% autoescape %} {% if foo != "bar" %} {% set foo = "bar" %} {% endif %} {% endautoescape %}
Use
verbatim
to treat multiple lines as raw text:{% verbatim %} {% if foo != "bar" %} {% set foo = "bar" %} {% endif %} {% endverbatim %}
-
might want to also add the |raw filter here for completeness as the question does say "prevent it from being processed"? – billythekid Jan 24 '17 at 17:23