Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
templates: move the globals up to the Environment (Jinja2 3.0.0) (#419)
* jinja: fix TemplateNotFound missing name The TemplateNotFound exception requires a parameter, name, that is missing in one of the calls. File "/usr/lib/python3.8/site-packages/salt/utils/jinja.py", line 158, in get_source raise TemplateNotFound TypeError: __init__() missing 1 required positional argument: 'name' This patch add the missing parameter in the raise call. Signed-off-by: Alberto Planas <[email protected]> * templates: move the globals up to the Environment When creating a Jinja2 environment, we populate the globals in the Template object that we generate from the environment. This cause a problem when there is a {% include "./file.sls" %} in the template, as cannot find in the environment globals information like the "tpldir", for example, making the relative path to be unresolved. Seems that in Jinja2 2.X this behaviour is not present, so attaching the globals to the Template will make the include to work, but since Jinja2 3.0.0 this is not the case. Maybe related with the re-architecture from pallets/jinja#295 This patch populate the globals in the Environment level, making this and other variables reachable by the Jinja templates. Fix #55159 Signed-off-by: Alberto Planas <[email protected]>
- Loading branch information