Django and Mustache use the same syntax for the model


I try to smuggle HTML template in the HTML for mustache.js, however the django template engine remove all the placeholders that should be output as-is to the front-end

The template is included in HTML in this way:

<script type="text/x-mustache-template" data-id="header_user_info">
    <div id="header_user_info">
        <div id="notification">0</div>
        <a href="#">{{username}}</a>

and I can get the HTML template by running $(el).html(), and generate html by using Mustache.to_html(temp, data);

I could put all the template into another static file and serve from CDN, but then it would be hard to track where the template belongs, and at least one extra http request.

You can use the {% templatetag %} templatetag to print out characters that would normally be processed by Django. For example:

{% templatetag openvariable %} variable {% templatetag closevariable %}

Results in the following in your HTML:

{{ variable }}

For a full list of arguments see: