I want to use AngularJS with Django however they both use {{ }}
as their template tags. Is there an easy way to change one of the two to use some other custom templating tag?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- Django __str__ returned non-string (type NoneType)
- void before promise syntax
- Keeping track of variable instances
For AngularJS v1.3.3 you should define your own template tags like this
AngularJS module
Webpage
you can maybe try verbatim Django template tag and use it like this :
We created a very simple filter in Django 'ng' that makes it easy to mix the two:
foo.html:
The
ng
filter looks like this:You can tell Django to output
{{
and}}
, as well as other reserved template strings by using the{% templatetag %}
tag.For instance, using
{% templatetag openvariable %}
would output{{
.I vote against using double parentheses (()) as template tag. It may work well as long as no function call is involved but when tried the following
with Firefox (10.0.2) on Mac I got a terribly long error instead of the intended logic. <[]> went well for me, at least up until now.
Edit 2012-03-29: Please note that $invalidWidgets is deprecated. However I'd still use another wrapper than double braces. For any angular version higher than 0.10.7 (I guess) you could change the wrapper a lot easier in your app / module definition:
API docs.
You could always use ng-bind instead of {{ }} http://docs.angularjs.org/api/ng/directive/ngBind