bottle icon indicating copy to clipboard operation
bottle copied to clipboard

Is there an obvious way to set jinja2 environment attributes?

Open PyB1l opened this issue 5 years ago • 2 comments

I want to use jinja-assets-compressor in our bottlepy based platform.

Is there an easy way to override default Bottle Jinja Environment?

PyB1l avatar Jun 12 '19 22:06 PyB1l

Ok, it IS pretty obvious:

Jinja2Template.settings = { 'extensions': [CompressorExtension] }

PyB1l avatar Jun 12 '19 23:06 PyB1l

Ok, thats how you add extension on bottlepy Jinja2 env.

I actually want to set some attributes on JInja2 Environment: For instance this is the process described on jinja-assets-compressor:

env = jinja2.Environment(extensions=[CompressorExtension]) env.compressor_output_dir = './static/dist' env.compressor_static_prefix = '/static' env.compressor_source_dirs = './static_files'

With bottle we can replace the first line with:

bottle.Jinja2Template.settings = { 'extensions': [CompressorExtension] }

But so far i was unable to replace the other lines? any suggertsions?

PyB1l avatar Jun 13 '19 10:06 PyB1l