{"id":13419730,"url":"https://github.com/mjumbewu/django-jstemplate","last_synced_at":"2025-03-16T23:31:33.206Z","repository":{"id":4556531,"uuid":"5697475","full_name":"mjumbewu/django-jstemplate","owner":"mjumbewu","description":"Embed Javascript templates (mustache.js and more) into Django templates with minimal fuss.","archived":false,"fork":false,"pushed_at":"2023-03-08T23:07:41.000Z","size":294,"stargazers_count":40,"open_issues_count":6,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T20:26:51.052Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjumbewu.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-09-06T04:31:05.000Z","updated_at":"2023-02-28T07:41:10.000Z","dependencies_parsed_at":"2022-09-16T14:22:00.451Z","dependency_job_id":"e92c6c36-c3c1-4902-9763-2142f87af1a7","html_url":"https://github.com/mjumbewu/django-jstemplate","commit_stats":{"total_commits":184,"total_committers":12,"mean_commits":"15.333333333333334","dds":"0.10869565217391308","last_synced_commit":"e30557dd95299f7e13a300efd61eee5b5c84a73d"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjumbewu%2Fdjango-jstemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjumbewu%2Fdjango-jstemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjumbewu%2Fdjango-jstemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjumbewu%2Fdjango-jstemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjumbewu","download_url":"https://codeload.github.com/mjumbewu/django-jstemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243832546,"owners_count":20355113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:19.940Z","updated_at":"2025-03-16T23:31:32.717Z","avatar_url":"https://github.com/mjumbewu.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"=================\ndjango-jstemplate\n=================\n\n.. image:: https://travis-ci.org/mjumbewu/django-jstemplate.png\n   :alt: Build Status\n   :target: https://travis-ci.org/mjumbewu/django-jstemplate\n.. image:: https://coveralls.io/repos/mjumbewu/django-jstemplate/badge.png?branch=master\n   :alt: Coverage Status\n   :target: https://coveralls.io/r/mjumbewu/django-jstemplate\n.. image:: https://img.shields.io/pypi/v/django-jstemplate.svg\n   :target: https://pypi.org/project/django-jstemplate/\n.. image:: https://img.shields.io/pypi/dm/django-jstemplate.svg\n   :target: https://pypi.org/project/django-jstemplate/\n\nA templatetag framework for easier integration of `mustache.js`_, `dust.js`_,\n`handlebars.js`_, or other JavaScript templates with Django templates. Also will\nwrap your templates in elements expected for libraries such as `ICanHaz.js`_.\nDjango-jstemplates is extensible, so if your favorite template library is not\nincluded, it's easy to add.  Inspired by `django-icanhaz`_.\n\n.. _mustache.js: http://mustache.github.com/\n.. _dust.js: http://akdubya.github.com/dustjs/\n.. _handlebars.js: http://handlebarsjs.com/\n.. _ICanHaz.js: http://icanhazjs.com/\n.. _django-icanhaz: http://github.com/carljm/django-icanhaz\n\nQuick Usage\n-----------\n\n(Read the full docs on `Read the Docs`_)\n\n.. _Read the Docs: http://django-jstemplate.readthedocs.org/en/latest/\n\nAdd ``\"jstemplate\"`` to your ``INSTALLED_APPS`` setting.\n\nDownload the templating library of your choice (I like to go straight\nmustache.js)::\n\n    wget https://raw.github.com/janl/mustache.js/master/mustache.js\n    mv mustache.js app/static/libs/\n\n``app/jstemplates/main.mustache``::\n\n    \u003cdiv\u003e\n      \u003cp\u003eThis is {{ name }}'s template\u003c/p\u003e\n    \u003c/div\u003e\n\n``app/templates/main.html``::\n\n    {% load jstemplate %}\n\n    \u003chtml\u003e\n    \u003chead\u003e\n      \u003cscript src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js\"\u003e\u003c/script\u003e\n      \u003cscript src=\"{{ STATIC_URL }}libs/mustache.js\"\u003e\u003c/script\u003e\n      \u003cscript src=\"{{ STATIC_URL }}libs/django.mustache.js\"\u003e\u003c/script\u003e\n    \u003c/head\u003e\n\n    \u003cbody\u003e\n      \u003cdiv id=\"dynamic-area\"\u003e\u003c/div\u003e\n\n      {% mustachejs \"main\" %}\n\n      \u003cscript\u003e\n        $(document).ready(function() {\n\n          var $area = $('#dynamic-area')\n            , template;\n\n          template = Mustache.template('main');\n          $area.html(template.render());\n\n        });\n      \u003c/script\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n\n\nRunning tests\n-------------\n\nTo run the tests (for development), install ``mock`` and ``six`` and run::\n\n    jstemplate/tests/project/manage.py test\n\n\nRationale\n---------\n\nThe collision between Django templates' use of ``{{`` and ``}}`` as template\nvariable markers and `mustache.js`_' use of same has spawned a variety of\nsolutions. `One solution`_ simply replaces ``[[`` and ``]]`` with ``{{`` and\n``}}`` inside an ``mustachejs`` template tag; `another`_ makes a valiant attempt\nto reconstruct verbatim text within a chunk of a Django template after it has\nalready been mangled by the Django template tokenizer.\n\nI prefer to keep my JavaScript templates in separate files in a dedicated\ndirectory anyway, to avoid confusion between server-side and client-side\ntemplating. So this solution is essentially just an \"include\" tag that avoids\nparsing the included file as a Django template.\n\nEnjoy!\n\n.. _one solution: https://gist.github.com/975505\n.. _another: https://gist.github.com/629508\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjumbewu%2Fdjango-jstemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjumbewu%2Fdjango-jstemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjumbewu%2Fdjango-jstemplate/lists"}