Skip to main content

Django Ember.js integration

Project description

Django Ember

https://secure.travis-ci.org/noirbizarre/django-ember.png

Django Ember help integrates Ember.js in Django. It use Django.js as base and is inspired from:

Installation

You can install Django Ember with pip:

pip install django-ember

or with easy_install:

easy_install django-ember

Add djangojs and ember to your settings.INSTALLED_APPS.

Django Ember depends on Django.js. It will be installed by pip/easy_install. If you want to use Django.js feature, add djangojs to your settings.INSTALLED_APPS.

Template tags

Loading template tags

You can either:

  • load the template tag lib into each template manually:

{% load ember %}
  • load the template tag lib by adding to your views.py:

from django.template import add_to_builtins

add_to_builtins('ember.templatetags.ember')

JS Libraries templates tags

Tag

JS Library

{% handlebars_js %}

Handlebars.js (1.0.rc.1)

{% ember_js %}

Ember.js (b6c33ae8ee7f84312b75de0c9b42c6d86df2ee14)

{% ember_data_js %}

Ember Data (2ac66cd2df43d17fd25386272d526807a9719c3d)

{% tastypie_adapter_js %}

Ember Data Tatypie Adapter (300ae64b31cce319da009fe1aed2bc9bc2838ed3)

{% ember_full_js %}

Ember.js + Handlebars.js + jQuery (optionnal)

{% emberpie_js %}

Ember.js + Handlebars.js + jQuery (optionnal) + Ember Data + Tastypie Adapter

Exemple:

<head>
{% ember_full_js %}
...
</head>

Will render into insert the follwing JS lib script tags:

  • Ember.js

  • Handlebars.js

  • jQuery

jQuery loading is optionnal for {% ember_full_js %} and {% emberpie_js %} tags. Simply set jquery keyword to false:

{% ember_full_js jquery=false %}
{% emberpie_js jquery=false %}

JS Template helpers

Django Ember the {% handlebars %} allow to easily write handlebars template for Ember.js. Call the template tag, and write your Handlebars template:

{% handlebars "tpl-infos" %}
    {{total}} {% trans "result(s)." %}
    <p>{% trans "Min" %}: {{min}}</p>
    <p>{% trans "Max" %}: {{max}}</p>
{% endhandlebars %}

The following block will be rendered in your page:

<script type="text/x-handlebars" data-template-name="tpl-infos">
    {{total}} result(s).
    <p>Min: {{min}}</p>
    <p>Max: {{max}}</p>
<script>

LICENSE

  • Lesser GNU Public License

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

Changelog

Current

  • Depends on and extend django.js

  • Upgraded to Handlebars 1.0.rc.1

  • Upgraded to Ember.js 1.0.0-pre.2

  • Upgraded to latest Ember Data git version

  • Make jquery optionnal for {% ember_full_js %} and {% emberpie_js %}

  • Support query string in TastypieAdapater (thanks to Peter Sutton/dj-foxxy)

0.1 (2012-08-06)

  • Initial release

Project details


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