check variable type inside Jinja2 in Flask -
the template file created contains this:
{% if type({'a':1,'b':2}) dict %} print "oh yes!!" {% else %} print "oh no!!!" {% endif %}
then jinja2 responds saying:
templateassertionerror: no test named 'dict'
i new jinja2 , flask
you looking mapping
test:
{% if {'a': 1, 'b': 2} mapping %} "oh yes!" {% else %} "oh no!" {% endif %}
jinja not python though, don't have access builtins (type
, print
not exist, example, unless add them the context. in flask, context_processor
decorator).
you don't need print
@ all. default output (unless in child template extends
parent, in case can interesting things null master fallback because blocks names available in master template output).
Comments
Post a Comment