Allow env_options in `Jinja2Templates#1401
Merged
Conversation
aminalaee
commented
Jan 9, 2022
|
|
||
| loader = jinja2.FileSystemLoader(directory) | ||
| env = jinja2.Environment(loader=loader, autoescape=True) | ||
| env_options.setdefault("loader", loader) |
Contributor
Author
There was a problem hiding this comment.
We can decide if we want to allow loader to be passed in env_options or not. The point is if we add it it makes directory reduntant but allows user full control over the loader.
env_options in `Jinja2Templatesenv_options in `Jinja2Templates
Contributor
Author
|
The documentation was not done yet. Can you check again? |
Contributor
|
Yup - I oughta have noted that. 😅 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #427
Allows
Jinja2Templatesto set Jinja2Environmentoptions here.For example:
Or:
Since
directoryis still a required argument, it will be passed in this case, but the loader passed will take precedence over thedirectoryand the loader created by Starlette. I can't think of any way to handle this right now, until maybe we can consider another API for Jinja2Templates later. This way we can deal with issues like #1214 .