librelist archives

« back to archive

Embedded controllers?

Embedded controllers?

From:
Torrance Hodgson
Date:
2013-11-10 @ 21:55
Hi all,

Symfony2 has the neat ability to embed controllers into templates, e.g.: 
http://symfony.com/doc/current/book/templating.html#embedding-controllers

This also has the side affect that you can use Edge Side Includes by 
delegating the rendering on the embedded controller on to your reverse 
proxy of choice, eg. Varnish.

Does Flask have the capability for something similar?

Thanks,
Torrance

Re: [flask] Embedded controllers?

From:
Marius Räsener
Date:
2013-11-10 @ 22:08
Hi Torrance,

I think what you want could be done simply be handing over the f.e. 
'articles' with the return function of your view...
There are different ways to return the same globally if you want to (g 
object i think)

But i'm still a newbie with flask so somebody else might answer that, too ;)

Greetings,
Marius

> Am 10.11.2013 um 22:57 schrieb "Torrance Hodgson" <torrance123@gmail.com>:
> 
> Hi all,
> 
> Symfony2 has the neat ability to embed controllers into templates, e.g.:
http://symfony.com/doc/current/book/templating.html#embedding-controllers
> 
> This also has the side affect that you can use Edge Side Includes by 
delegating the rendering on the embedded controller on to your reverse 
proxy of choice, eg. Varnish.
> 
> Does Flask have the capability for something similar?
> 
> Thanks,
> Torrance

Re: [flask] Embedded controllers?

From:
Slava Bacherikov
Date:
2013-11-11 @ 11:32
10.11.2013 23:55, Torrance Hodgson пишет:
> Hi all,
>
> Symfony2 has the neat ability to embed controllers into templates, e.g.:
http://symfony.com/doc/current/book/templating.html#embedding-controllers
>
> This also has the side affect that you can use Edge Side Includes by 
delegating the rendering on the embedded controller on to your reverse 
proxy of choice, eg. Varnish.
>
> Does Flask have the capability for something similar?
>
> Thanks,
> Torrance
HI, I created example for flask >= 0.10
https://gist.github.com/bacher09/7411777 and flask < 0.10
https://gist.github.com/bacher09/7411829 .

-- 
Slava Bacherikov <slava@bacher09.org>

Re: [flask] Embedded controllers?

From:
gioi
Date:
2013-11-11 @ 13:37
Strictly speaking, Flask is not a MVC framework as Symfony, so IMHO
there's no notion of controller.
BTW, I would use Jinja2 macros and @app.context_processor.

Re: [flask] Embedded controllers?

From:
Torrance Hodgson
Date:
2013-11-11 @ 20:07
Thanks for all the helpful replies! I think Slava’s solution of an 
@app.template_global() function works best for my case.

Torrance


On 12/11/2013, at 12:32 am, Slava Bacherikov <bacher09@yandex.ru> wrote:

> 10.11.2013 23:55, Torrance Hodgson пишет:
>> Hi all,
>> 
>> Symfony2 has the neat ability to embed controllers into templates, 
e.g.: 
http://symfony.com/doc/current/book/templating.html#embedding-controllers
>> 
>> This also has the side affect that you can use Edge Side Includes by 
delegating the rendering on the embedded controller on to your reverse 
proxy of choice, eg. Varnish.
>> 
>> Does Flask have the capability for something similar?
>> 
>> Thanks,
>> Torrance
> HI, I created example for flask >= 0.10
> https://gist.github.com/bacher09/7411777 and flask < 0.10
> https://gist.github.com/bacher09/7411829 .
> 
> -- 
> Slava Bacherikov <slava@bacher09.org>
>