Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.11 KB

README.md

File metadata and controls

54 lines (43 loc) · 1.11 KB

django-jsmetatemplates

Template tag library for building building javascript templates using django templates

Allows for javascript templates (like mustache.js ones) to be built using the inheritence and include functionality of django-templates before being rendered to the client.

Gets around the problem of overlapping delimiters by using a different delimiter for javascript templates that is then turned into the correct one during django template rendering.

An example:

js_template_base.html:

<div>
	<h1>{! title !}</h1>
	{% block content %}
	{% endblock %}
</div>

js_template_derivative.html:

{% extends 'js_template_base.html' %}

{% block content %}
<ul>
	<li>{! thing_one !}</li>
	<li>{! thing_two !}</li>
</ul>
{% endblock %}

page_template.html:

{% load jsmetatemplate %}

{% include_ichtemplate "js_template_derivative.html" %}

page_template.html will then render to:

<script type="text/html" id="js_template_derivative.html">
<div>
	<h1>{{ title }}</h1>
	<ul>
		<li>{{ thing_one }}</li>
		<li>{{ thing_two }}</li>
	</ul>
</div>
</script>