Package: django-jstemplate
A templatetag framework for easier integration ofmustache.js,dust.js,handlebars.js, or other JavaScript templates with Django templates. Also will
wrap your templates in elements expected for libraries such asICanHaz.js.
Django-jstemplates is extensible, so if your favorite template library is not
included, it’s easy to add.  Inspired bydjango-icanhaz.Quick Usage(Read the full docs onRead the Docs)Add"jstemplate"to yourINSTALLED_APPSsetting.Download the templating library of your choice (I like to go straight
mustache.js):wget https://raw.github.com/janl/mustache.js/master/mustache.js
mv mustache.js app/static/libs/app/jstemplates/main.mustache:<div>
  <p>This is {{ name }}'s template</p>
</div>app/templates/main.html:{% load jstemplate %}

<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
  <script src="{{ STATIC_URL }}libs/mustache.js"></script>
  <script src="{{ STATIC_URL }}libs/django.mustache.js"></script>
</head>

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

  {% mustachejs "main" %}

  <script>
    $(document).ready(function() {

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

      template = Mustache.template('main');
      $area.html(template.render());

    });
  </script>
</body>
</html>Running testsTo run the tests (for development), installmockandsixand run:jstemplate/tests/project/manage.py testRationaleThe collision between Django templates’ use of{{and}}as template
variable markers andmustache.js’ use of same has spawned a variety of
solutions.One solutionsimply replaces[[and]]with{{and}}inside anmustachejstemplate tag;anothermakes 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 this solution is essentially just an “include” tag that avoids
parsing the included file as a Django template.Enjoy!CHANGES2.0.1Fix pacthing of the makemessages command to work for Django later than 1.11.2.0.0Thank you to @karlrl for the following changes:Support Python 3.7-3.10Support Django 2.2-4.1Drop support for Python<3.7 and Django<3.21.3.9In order to support the latest versions of Django, removed dependence on the
FILE_CHARSET setting.  This means that the templates will always be read as
UTF-8.1.3.8Bug fix: Update to work with Django 1.91.3.7Bug fix: Fail silently when using an invalid regex to match templates.1.3.6Bug fix: Fix the case oninnerHTML(wasinnerHtml)1.3.5Usedocument.getElementByIdandinnerHtmlinstead of depending on jQuery
to get the text of handlebars templates.Switch the order of precompiling and registering partials in handlebars tag,
so that partials can used compiled template.1.3.4Fix compatibility with Python 3.2. Explicity unicode literals (i.e., u’…’)
are not supported in Python 3.2 and cause a syntax error. Support was revived
in Python 3.3. Python 2.6 and 2.7 allow using unicode string literals by
default withfrom __future__ import unicode_literals, so we use that here.1.3.3Sort translatable strings so that results are consistent across Python
versions.1.3.2All template renderers handle unicode characters.1.3.1Bug fix: Closure that was registering Handlbars partials was not wrapped in
parentheses.1.3.0Add a short translation form:{{ _ 'this is translatable' }}1.2.1Allow optional precompiling and and registering of partials for the
Handlebars.js tag. For example:{% handlebarsjs '(.*)' precompile register_partials }This will add atemplatesobject toHandlebars, and register all
templates for use as partials.1.2.0Add Handlebars.js support1.1.1Fix setup script requirements1.1.0Python 3 support!1.0.3Move the static/mustache/js/ folder to static/libs/1.0.2Update MANIFEST file to use “jstemplate” folder instead of “mustachejs”1.0.1Simplify the template tag methods, and get rid of unused imports in the
template tag modulesUpdate project references in the docs1.0.0Rename project to “django-jstemplate” (from “django-mustachejs”)Rename the “mustacheraw” template tag to “rawjstemplate”Rename the “mustacheich” template tag to “icanhazjs”0.8.3Fix incorrect identifier name in makemessages command0.8.2Fix the FilesystemRegexFinder to match exactly the extensions specified in
the configuration, and no more0.8.1Fix makemessages to work with recent code updates0.8.0Have the regex finder respect the MUSTACHEJS_EXTS settingUpdate normal file finders to use glob patterns0.7.4Fix i18n preprocessor for python 2.6 compatibility0.7.3Correctly escaped translated strings.0.7.2Changed search pattern to be non-greedy.0.7.1Handle translation strings with new lines.0.7.0Pulled 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.0.6.0Adddustjstag to insert a script block to create a compiled dustjs
template.  Thanks toGehan Gonsalkorale.0.5.0Addmustacherawtag to insert just the raw text of a mustacehe template.
Thanks to Greg Hinch.Addmustacheichtag 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’sFILE_CHARSETsetting. Thanks Eduard Iskandarov.Fixed template-finding failure with non-normalized directories inMUSTACHEJS_DIRS. Thanks Eduard Iskandarov for report and patch.0.4.0Add the MUSTACHEJS_EXTS configuration variable for specifying the extensions
allowed for template files located by the FilesystemFinder (and, by extension,
the AppFinder).0.3.3Add a package_data value to the setup call0.3.2Add the MANIFEST.in file itself as an entry in MANIFEST.in.0.3.0Change 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_DIRis nowICANHAZ_DIRS(a list); addedICANHAZ_FINDERS,ICANHAZ_APP_DIRNAMES, and finding of
templates in installed apps.0.1.0 (2011.06.22)Initial release.TODO