Relative path imports inside templates loaded with a Jinja PrefixLoader

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Relative path imports inside templates loaded with a Jinja PrefixLoader



I am working on a Flask app which uses jinja2's PrefixLoader and PackageLoader in conjunction as follows:


app.jinja_loader = PrefixLoader(
'app': PackageLoader('flask_skeleton_ui'),
'govuk_frontend': PackageLoader('govuk_frontend_jinja', 'govuk-frontend/src/')
)



Thereby allowing me to load templates like this:


% extends "govuk_frontend/template.html" %



However, jinja appears to be struggling to find templates inside the govuk_frontend package which use relative imports, such as:


% from "./components/skip-link/macro.html" import govukSkipLink %



What I would expect to happen is for that to be resolved relative to the parent template inside the package. But it doesn't seem to be and a TemplateNotFound exception is thrown.



Should this work? Or have I misunderstood something?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered