title: Avoiding ambiguous mustaches from Jinja2 that includes jQuery templates
body: <p>I'm trying to insert <a href="http://api.jquery.com/jQuery.template/" rel="noreferrer">jQuery templates</a> into <a href="http://jinja.pocoo.org/docs/api/" rel="noreferrer">Jinja2</a> templates. Alas they both (in the default setup) use the mustaches <code>{{</code> &amp; <code>}}</code> to indicate expressions and literals, respectively.</p>
  
  <p>I'm inserting my jQuery templates into HTML with <code>script</code> tags, like this:</p>
  
  <pre><code>&lt;script type='text/x-jquery-template'&gt;
      &lt;div&gt;The people are:
           {{ each people }} 
            ${$value}
           {{ /each }}
      &lt;/div&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>If the above is in a Jinja template, however, it balks because Jinja tries to interpret <code>each</code> as a literal.</p>
  
  <p>In the circumstances (we've lots of templates already) it isn't practical to change Jinja2's start and end delimiters for variables. Plus it's confusing, decreases interoperability, and requires extra training. It is preferable to avoid this option.</p>
  
  <p>So the two alternative things I've thought of to solve this are:</p>
  
  <ol>
  <li><p>Jinja2 escaping each '{{' and '}}', which I'm not quite sure how to do best ("{{ "{{" }}`, perhaps, but that's verbose);</p></li>
  <li><p>More practical - perhaps ideal - would be telling Jinja2 to <em>not</em> parse a block of code, perhaps via a jQuery extension.</p></li>
  </ol>
  
  <p>I'd be grateful for thoughts and feedback. Thank you for reading.</p>