Mixing Handlebars templates and Django templates


Are any of you using Ember in conjunction with Django? We’re starting a new application at my company with Ember/Django and were curious how others are handling the overlap in delimiter characters and the possibility of having an Ember script tag in a Django template. A coworker used this solution which seems to have worked:


But wanted to see what others are using.


If you are using django 1.5 you can use the verbatim tag in your django templates to avoid an error (assuming you are having trouble w/ the {{ style syntax that both django + ember use)


If you are on 1.4 or 1.3 you can use an external egg

pip install django-templatetag-handlebars

Then you can do something like this

{% load templatetag_handlebars %} {% verbatim %}

<script type="text/x-handlebars" data-template-name="application"> {{outlet}} </script>

{% endverbatim %}


We’re on 1.4.

We decided to go with the raw option as mentioned on Adrian’s website: http://www.holovaty.com/writing/django-two-phased-rendering/ I’m sure it’s identical to the verbatim tag.


Just an update. We upgraded to Django 1.5 that includes the {% verbatim %} tag which does the same thing.