node.jsangularjsswig-template

Escaping the double curly braces {{ }} in Swig templates for AngularJS


Swig templates and AngularJS both use the double curly brace notation. How can the double curlies be escaped in Swig for Angular?


Solution

  • Double curlies can be escaped with

    {% raw %}
    
    eg: {% raw %}{{ foobar }}{% endraw %}
    

    Forces the content to not be auto-escaped. All swig instructions will be ignored and the content will be rendered exactly as it was given. See Swig manual/tags/raw.