Syntax error in python flag triangle

Since I wanted to use AngularJS in combination with Flask, I was looking for a cool tool to properly handle these frameworks, as Jinja and Angular will have problems with each other. I found a Triangle that is pretty cool and works, but only to a certain point. For example, such things work, 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 this, I get the following error

jinja2.exceptions.TemplateSyntaxError

TemplateSyntaxError: unexpectedly char u '$' at 875

Am I doing something wrong or in this case a limited frame? Help is much appreciated.

+4
source share
2 answers

, $ Jinja .

Angular :

var app = angular.module('Application', []);

app.config(['$interpolateProvider', function($interpolateProvider) {
  $interpolateProvider.startSymbol('{a');
  $interpolateProvider.endSymbol('a}');
}]);

, , . > Angular, {a some_variable a}.

+5

angular, , angular .

<span>
    <a href="#/posts/{{'$index'|angular}}">Comments</a>
</span>

angular, https://github.com/morgan-del/flask-triangle

def angular_filter(value):
    """
    A filter to tell Jinja2 that a variable is for the AngularJS template
    engine.
    If the variable is undefined, its name will be used in the AngularJS
    template, otherwise, its content will be used.
    """

    if is_undefined(value):
        return '{{{{{}}}}}'.format(value._undefined_name)
    if type(value) is bool:
        value = repr(value).lower()
    return '{{{{{}}}}}'.format(value)
+4

All Articles