Since I wanted to use AngularJS in combination with Flask, I searched for a cool tool to handle these frameworks properly since Jinja and Angular would have problems with each other. I found Triangle which is pretty cool and working but just up to a certain point. Stuff like this works for example:
<a ng-show="post.link" href="{{post.link|angular}}">
{{post.title|angular}}
</a>
But on the other hand this does not work:
<span>
<a href="#/posts/{{$index|angular}}">Comments</a>
</span>
When I try to do that, I receive following error
jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: unexpected char u'$' at 875
Am I doing something wrong or is the framework just limited in that case? Help is highly appreciated.
As the error message is saying, $
cannot be used in Jinja as part of a variable.
Instead, you'll need to change Angular's delimiter notation:
var app = angular.module('Application', []); app.config(['$interpolateProvider', function($interpolateProvider) { $interpolateProvider.startSymbol('{a'); $interpolateProvider.endSymbol('a}'); }]);
Whatever is chosen for the start and end symbols will act as the new delimiters. In this case, you would express a variable > to Angular using {a some_variable a}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With