8
8
891099838382014-11-27 23:56:29
Flask
89109983838, 2014-11-27 23:56:29

How to call fuses from the temple?

Is it possible to call views from a template and get values ​​from them in a worthless raid.
The result of the context processor is passed to all page templates, but we would like to selectively (if necessary, call several views from certain child templates).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly Scherbakov, 2014-11-28
@89109983838

First, please use normal terminology.
Second: when you call the template, you are passing Jinja2 a list of variables, right? You can also include the view functions that you need in this list and immediately call them in the template. Approximately as follows.

env.get_template("my_template.html").render({
    'my_view': my_view,
})

<div>{{ my_view() }}</div>

8
89109983838, 2014-12-09
@89109983838

Thank you! I will work on the terminology and read the manual more carefully...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question