I do a few webprojects with
Flask
and I love it!
While creating a template i searched for a way to call functions from within the template, and found out that i can use a @app.context_processor
decorator.
|
|
In the jinja2 template you can now simply call the functions like this:
|
|
Lets assume news contains 2 elements, the result looks like this:
|
|
The important part is return dict(date_now=date_now, baz=foo)
. The first word is the key, the value is a function pointer.
The key is the keyword you write in your template code {{ baz() }}
for example, foo
is the name of the function that get called.