Skip to main content

Django Ember.js integration

Project description

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

Django Ember help integrates Ember.js in Django.

Django Ember is inspired from:

Installation

You can install Django Ember with pip:

pip install django-ember

or with easy_install:

easy_install django-ember

Add ember 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 setting.py:

    from django.template.loader import add_to_builtins
    
    add_to_builtins('ember.templatetags.ember')

JS Libraries templates tags

Tag

JS Library

{% handlebars_js %}

Handlebars.js (1.0.beta.6)

{% jquery_js %}

jQuery (1.7.2)

{% ember_js %}

Ember.js (1.0.pre)

{% ember_data_js %}

Ember Data (git)

{% tastypie_adapter_js %}

Tastypie Adapter for Ember Data (git)

{% ember_full_js %}

Ember.js + Handlebars.js + jQuery

{% emberpie_js %}

Ember.js + Handlebars.js + jQuery + 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

JS Template helpers

Django Ember provide 2 template tags to ease the JS templating: handlebars and verbatim

handlebars

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 with end-up 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>

verbatim

A {% verbatim %} tag is available to escape a specific part. For example, you may want a subpart of your template to be rendered by Django

<script type="text/x-handlebars" id="tpl-django-form">
    <form>
        {% verbatim %}
            {{#if id}}<h1>{{ id }}</h1>{{/if}}
        {% endverbatim %}
        {{ yourform.as_p }}
    </form>
</script>

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-ember-0.1.tar.gz (105.2 kB view details)

Uploaded Source

File details

Details for the file django-ember-0.1.tar.gz.

File metadata

  • Download URL: django-ember-0.1.tar.gz
  • Upload date:
  • Size: 105.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-ember-0.1.tar.gz
Algorithm Hash digest
SHA256 1986fd3a5040d61f7c83e35b8f9568c01d1644041493e40c96bae60701f0ba88
MD5 df94c6f333983191a05844bfd4475a11
BLAKE2b-256 8a0d20c4b3118c96b3abda80ea851d4fee85db12814930b415e29cad35765d13

See more details on using hashes here.

Supported by

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