Using Python Flask Jinja2 with Mustache

Today I was building a single page web application using Python Flask framework and Backbone.js and faced a problem where Jinja2 was parsing the mustache template. Both Jinja2 and Mustache use {{}} in their templates. When a user makes a first request, I render index.html that contains all my mustache templates as well. The solution to avoid Jinja2 from parsing Mustache templates is to put all the templates inside  {% raw %} and {% endraw %} as shown below.

{% raw %}
<script type="text/template" id="company-template">
	<a href="#companies/{{id}}/jobs" class="list-group-item">
    	<h4 class="list-group-item-heading">{{name}}</h4>
    	<p class="list-group-item-text">{{description}}</p>
  </a>
</script>
{% endraw %}