librelist archives

« back to archive

What ways do we have to ship jinja macros and/or templates?

What ways do we have to ship jinja macros and/or templates?

From:
herr.kaste
Date:
2012-05-17 @ 14:35
I would like to ship a flask extension with some jinja macros and/or
templates. Anyone?


Regards
herr.kaste

Re: [flask] What ways do we have to ship jinja macros and/or templates?

From:
Simon Sapin
Date:
2012-05-17 @ 14:54
Le 17/05/2012 16:35, herr.kaste a écrit :
> I would like to ship a flask extension with some jinja macros and/or
> templates. Anyone?

I was gonna suggest fiddling with app.jinja_env.loader but there is 
simpler: use a blueprint. Either provide it to user to do whatever they 
want, or register it implicitly when initializing your extension for a 
given app.

-- 
Simon Sapin

Re: [flask] What ways do we have to ship jinja macros and/or templates?

From:
herr.kaste
Date:
2012-05-17 @ 15:04
Huh?

Then how to add a jinja-macro to a blueprint, same question.

2012/5/17 Simon Sapin <simon.sapin@exyr.org>

> Le 17/05/2012 16:35, herr.kaste a écrit :
> > I would like to ship a flask extension with some jinja macros and/or
> > templates. Anyone?
>
> I was gonna suggest fiddling with app.jinja_env.loader but there is
> simpler: use a blueprint. Either provide it to user to do whatever they
> want, or register it implicitly when initializing your extension for a
> given app.
>
> --
> Simon Sapin
>

Re: [flask] What ways do we have to ship jinja macros and/or templates?

From:
herr.kaste
Date:
2012-05-17 @ 21:46
Slowly, it sank on  me...
Am 17.05.2012 17:04 schrieb "herr.kaste" <herr.kaste@googlemail.com>:

> Huh?
>
> Then how to add a jinja-macro to a blueprint, same question.
>
> 2012/5/17 Simon Sapin <simon.sapin@exyr.org>
>
>> Le 17/05/2012 16:35, herr.kaste a écrit :
>> > I would like to ship a flask extension with some jinja macros and/or
>> > templates. Anyone?
>>
>> I was gonna suggest fiddling with app.jinja_env.loader but there is
>> simpler: use a blueprint. Either provide it to user to do whatever they
>> want, or register it implicitly when initializing your extension for a
>> given app.
>>
>> --
>> Simon Sapin
>>
>
>

Re: [flask] What ways do we have to ship jinja macros and/or templates?

From:
Simon Sapin
Date:
2012-05-17 @ 22:00
Le 17/05/2012 16:54, Simon Sapin a écrit :
> use a blueprint.


The template namespace for all blueprints and for the main app are 
"merged", there is no automatic prefix. So it is a good idea to have 
your own prefix (directory) in the template names. The directory 
structure ends up something like this:

my_extension/__init__.py
my_extension/templates/my_extension/foo.jinja2

The extension name is appears twice in the complete template filenames.

http://flask.pocoo.org/docs/blueprints/#templates

-- 
Simon Sapin