self.directory = Path(directory)
self.env_vars = dict(env_vars)
self.j2env = jinja2.Environment(
- loader=jinja2.FileSystemLoader(str(self.directory)),
+ loader=jinja2.FileSystemLoader(
+ [
+ str(self.directory),
+ str(ALL["srcdir"]), # to allow _common/ includes
+ ]
+ ),
undefined=jinja2.StrictUndefined,
variable_start_string="@",
variable_end_string="@",
variables which the engine was initialized with are also filled in. In
case of a variable name clash, `data` has precedence.
"""
+ available = self.j2env.list_templates()
if template is None:
template = f"{output}.j2.manual"
- if not Path(template).is_file():
+ if template not in available:
template = f"{output}.j2"
- if not Path(template).is_file():
- raise RuntimeError('No jinja2 template found for "{output}"')
+ if template not in available:
+ raise RuntimeError(f'No jinja2 template found for "{output}"')
if data is None:
data = {**self.env_vars}