python Flask Triangle中的语法错误 [英] Syntax Error in python Flask Triangle
问题描述
< a ng-show =post.linkhref ={{post。链路|角}}>
{{post.title | angular}}
< / a>
但是另一方面,这是行不通的:
< span>
< a href =#/ posts / {{$ index | angular}}>评论< / a>
< / span>
当我尝试这样做时,我收到以下错误:
jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError:意外的字符'$'at 875
我做错了什么,或者只是在这种情况下,框架是有限的吗?帮助非常感谢。
正如错误信息所示, $
不能在 Jinja作为变量的一部分中使用。
相反,您需要更改Angular的分隔符:
var app = angular.module('Application',[]);
$ b app.config(['$ interpolateProvider',function($ interpolateProvider){
$ interpolateProvider.startSymbol('{a');
$ interpolateProvider.endSymbol('a }');
}]);
无论选择什么开始和结束符号,都将作为新的分隔符。在这种情况下,您可以使用{a some_variable a}来表示一个变量> Angular。
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}.
这篇关于python Flask Triangle中的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!