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

templates: move the globals up to the Environment (Jinja2 3.0.0) #419

Merged
merged 2 commits into from
Aug 31, 2021

Commits on Aug 30, 2021

  1. 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]>
    aplanas committed Aug 30, 2021
    Configuration menu
    Copy the full SHA
    f804e62 View commit details
    Browse the repository at this point in the history
  2. 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]>
    aplanas committed Aug 30, 2021
    Configuration menu
    Copy the full SHA
    0ecbce4 View commit details
    Browse the repository at this point in the history