skip to navigation
skip to content

django-mustachejs 0.8.3-eol

A Django template tag for embedding Mustache.js templates safely.

NOTE: django-mustachejs is now named “django-jstemplate”!

The source is available at, and the package is at Please update your references.

Migration is easy:

  • In your settings’ INSTALLED_APPS, mustachejs becomes jstemplate
  • MUSTACHEJS_... settings become JSTEMPLATE_...
  • In your Django templates, {% load mustachejs %} becomes {% load jstemplate %}

That’s it. If you have any issues, get in touch with me on GitHub or on Twitter @mjumbewu. Thanks for using the project!


A templatetag framework for easier integration of mustache.js JavaScript templates with Django templates. Inspired by ICanHaz.js, django-icanhaz, and jquery.mustache.

NOTE: Though django-mustachejs was originally developed for mustache-style templates, it can actually be used to embed any type of client-side templates. It might be better named django-jstemplates or something like that.

Quick Usage

(Read the full docs on Read the Docs)

Add "mustachejs" to your INSTALLED_APPS setting.


  <p>This is {{ name }}'s template</p>


{% load mustachejs %}

  <script src=""></script>
  <script src="{{ STATIC_URL }}mustache/js/mustache-0.3.0.js"></script>
  <script src="{{ STATIC_URL }}mustache/js/django.mustache.js"></script>

  <div id="dynamic-area"></div>

  {% mustachejs "main" %}

    $(document).ready(function() {

      var $area = $('#dynamic-area')
        , template;

      template = Mustache.template('main');


Rationale (from django-icanhaz)

The collision between Django templates’ use of {{ and }} as template variable markers and mustache.js’ use of same has spawned a variety of solutions. One solution simply replaces [[ and ]] with {{ and }} inside an mustachejs template tag; another makes a valiant attempt to reconstruct verbatim text within a chunk of a Django template after it has already been mangled by the Django template tokenizer.

I prefer to keep my JavaScript templates in separate files in a dedicated directory anyway, to avoid confusion between server-side and client-side templating. So my contribution to the array of solutions is essentially just an “include” tag that avoids parsing the included file as a Django template (and for convenience, automatically wraps it in the script tag that ICanHaz.js expects to find it in).




  • End-of-life. The project is now maintained at django-jstemplates.


  • Fix incorrect identifier name in makemessages command


  • Fix the FilesystemRegexFinder to match exactly the extensions specified in the configuration, and no more


  • Fix makemessages to work with recent code updates


  • Have the regex finder respect the MUSTACHEJS_EXTS setting
  • Update normal file finders to use glob patterns


  • Fix i18n preprocessor for python 2.6 compatibility


  • Correctly escaped translated strings.


  • Changed search pattern to be non-greedy.


  • Handle translation strings with new lines.


  • Pulled in commit from django-icanhaz to load templates using regular expressions.
  • Added preprocessing framework, and a preprocessor for i18n.
  • Hijack the makemessages command to find js template messages as well.


  • Add dustjs tag to insert a script block to create a compiled dustjs template. Thanks to Gehan Gonsalkorale.


  • Add mustacheraw tag to insert just the raw text of a mustacehe template. Thanks to Greg Hinch.
  • Add mustacheich tag to insert a mustache script block as icanhaz expects.

0.4.1 (2012.01.09)

  • Fixed template reading to explicitly decode template file contents using Django’s FILE_CHARSET setting. Thanks Eduard Iskandarov.
  • Fixed template-finding failure with non-normalized directories in MUSTACHEJS_DIRS. Thanks Eduard Iskandarov for report and patch.


  • Add the MUSTACHEJS_EXTS configuration variable for specifying the extensions allowed for template files located by the FilesystemFinder (and, by extension, the AppFinder).


  • Add a package_data value to the setup call


  • Add the file itself as an entry in


  • Change the name from django-icanhaz to django-mustachejs.
  • Remove dependency on ICanHaz.js. I like the library, but the maintainers were not responsive enough for now. Use Mustache.js straight, with a little bit of minimal sugar. Templates are rendered to straight Javascript.

0.2.0 (2011.06.26)

  • Made template-finding more flexible: ICANHAZ_DIR is now ICANHAZ_DIRS (a list); added ICANHAZ_FINDERS, ICANHAZ_APP_DIRNAMES, and finding of templates in installed apps.

0.1.0 (2011.06.22)

  • Initial release.


File Type Py Version Uploaded on Size
django-mustachejs-0.8.3-eol.tar.gz (md5) Source 2012-09-06 18KB
  • Downloads (All Versions):
  • 56 downloads in the last day
  • 521 downloads in the last week
  • 1952 downloads in the last month