jinja2-cli icon indicating copy to clipboard operation
jinja2-cli copied to clipboard

Specifying the search path for FileSystemLoader

Open ahmetb opened this issue 7 years ago • 3 comments

I have this directory structure on current workdir:

.
└── service
    ├── base.yaml
    ├── external
    │   └── base.yaml
    └── internal
        └── base.yaml

The ./service/internal/base.yaml has a {% extends "./service/base.yaml" %} which works correctly if I run the jinja2 module manually with:

from jinja2 import Environment, FileSystemLoader, select_autoescape
env = Environment(loader=FileSystemLoader('.'))
env.get_template('service/internal/base.yaml').render()

But running jinja2 CLI fails:

$ jinja2 service/external/base.yaml
...
jinja2.exceptions.TemplateNotFound: service/base.yaml

I think jinja2 tool needs to use the current workdir ($CWD) as the search directory (or have a --flag to signal a /path/to/templates).

ahmetb avatar Aug 17 '18 17:08 ahmetb

Hmm, seems like it would be an easy fix. I can try to whip something up, but if in the meantime you wanted to submit a fix, I'd happily review and merge it.

mattrobenolt avatar Aug 20 '18 20:08 mattrobenolt

I'm pretty bad at python so I'll defer to you :)

ahmetb avatar Aug 20 '18 21:08 ahmetb

meh, that's not a right fix.

mattrobenolt avatar Aug 27 '18 19:08 mattrobenolt