Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Is there an obvious way to set jinja2 environment attributes? #1147

Open
PyB1l opened this issue Jun 12, 2019 · 2 comments
Open

Is there an obvious way to set jinja2 environment attributes? #1147

PyB1l opened this issue Jun 12, 2019 · 2 comments

Comments

@PyB1l
Copy link
Contributor

PyB1l commented Jun 12, 2019

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

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

@PyB1l
Copy link
Contributor Author

PyB1l commented Jun 12, 2019

Ok, it IS pretty obvious:

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

@PyB1l PyB1l closed this as completed Jun 12, 2019
@PyB1l
Copy link
Contributor Author

PyB1l commented Jun 13, 2019

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 PyB1l reopened this Jun 13, 2019
@PyB1l PyB1l changed the title Is there an obvious way to use jinja2 extensions? Is there an obvious way to set jinja2 environment attributes? Jun 13, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant