# questions

Miguel Angel Ortiz Marin

01/17/2023, 3:24 PM
Hi team, wondering about some pointers for working with jinja2 templating. Facing the following pain point: • We're importing .j2 files that keep macros and some variables, however we can only import j2 files that are in the same folder or in subfolders: ◦ I Can do {% from "./countries.j2" import countries %} with no problem ◦ Can't do {% from "../countries.j2" import countries %} which ends giving an error • Ideally I'd keep a "global" templates folder from which macros and variables can be imported • Not sure if this is directly a kedro question. Wondering if some subclassing to TemplatedConfigLoader could do the trick


01/17/2023, 4:09 PM
Hi Miguel - so this has been done before, as of today you need to override one line in TemplatedConfigLoader to get it working. I’ll explain how to do this on the latest version of Kedro, however in the near future this will change as we move to OmegeConf which will introduce a whole host of new fancy features here. On this line where
is called you can provide a
argument which points to wherever you provide your global list of templates are, these will be in scope for any templating In the future this will be better, part of the reason OmegaConf is coming is because we’re in the process of rewriting and simplifying the config loader which has essentially existed since day 1 of Kedro and is well overdue a refactor.

Miguel Angel Ortiz Marin

01/18/2023, 8:25 PM
Thank you for all the detail!