Skip to main content

Easily embed Handlebars.js templates in your django templates

Project description

django-templatetag-handlebars allows you to embed Handlebars.js templates in your django templates.

Most of the template tag code comes from Miguel Araujo’s verbatim snippet.

INSTALL

pip install django-templatetag-handlebars

USAGE

  • Add templatetag_handlebars to your INSTALLED_APPS

  • Add the HTML header :

<head>
{% include "templatetag_handlebars/head.html" %}
...
</head>
  • Call the template tag :

{% load templatetag_handlebars %}

{% tplhandlebars "tpl-infos" %}
    {{total}} {% trans "result(s)." %}
    <p>{% trans "Min" %}: {{min}}</p>
    <p>{% trans "Max" %}: {{max}}</p>
{% endtplhandlebars %}
  • Render your block as usual using Handlebars.js API :

var properties = {
    total: 10,
    min: 5,
    max: 4
};

var template = Handlebars.compile($('#tpl-infos').html()),
    rendered = template(properties);

AUTHORS

makinacom

Similar tools

  • django-handlebars, by Chris Vigelius,

    which focuses on server-side Handlebars rendering.

LICENSE

  • Lesser GNU Public License

  • Handlebars.js is released under the MIT license - Copyright 2011 Yehuda Katz

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-templatetag-handlebars-1.0.1.tar.gz (17.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page