Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feature request: add support for jinja2 Environment options #124

Open
Kamilcuk opened this issue Dec 13, 2023 · 2 comments
Open

Feature request: add support for jinja2 Environment options #124

Kamilcuk opened this issue Dec 13, 2023 · 2 comments

Comments

@Kamilcuk
Copy link

Hi, it would be absolutely amazing to add the following options:

--trim_blocks
--lstrip_blocks

They would translate 1:1 to jinja2.Environment options.

Thanks!

@mattrobenolt
Copy link
Owner

I'm thinking maybe something a bit more generic for setting any of these:

https://github.com/mattrobenolt/jinja2-cli/blob/main/jinja2cli/cli.py#L264-L268

There's quite a lot of options here: https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment

And I think if we're going to get into configuring them, it might make sense to just allow you to set any of them more as key=value pairs.

So something like:

--env trim_blocks=True --env block_start_string={{

Or something and this can cover all bases.

Thoughts?

@Kamilcuk
Copy link
Author

Thoughts?

Hi. I would go with --trim_blocks --lstrip_blocks --block_start_string={{ options because it is simple and readable and easy and understandable and maintainable.

For --env trim_blocks=True --env block_start_string={{ you would have to write a custom conversion function that properly handles types - str, bool, int - depending on the option. This is work and is a maintenance burden, and the options will have to be enumerated anyway to get the type, and user error messages might be confusing --env invalidoption

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants