Skip to content

Template tag library for building building javascript templates using django templates

Notifications You must be signed in to change notification settings

louissobel/django-jsmetatemplates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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>

About

Template tag library for building building javascript templates using django templates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages