Open command-tab opened 10 years ago
This is annoying, yes, but it's mostly a problem with Jinja, not PyJade.
PyJade for jinja is implemented as a jinja extension that preprocesses source templates on demand and does no actual file loading -- pyjade just gets passed the template source that jinja loaded, translates it into jinja syntax (so include x
becomes {% include "x.jade" %}
), and returns it to jinja.
It looks like you can modify your jinja environment to do what you want, though:
The issue here is that Jade supports both relative and absolute (relative to jade's basedir
) paths for include
and extend
, where the absolute paths are prefixed with /
, but Jinja's commonly used template loaders treat all paths as absolute from the root template directory.
The alternative, I guess, would be for pyjade to do some fancy include
-rewriting when using jinja
mode, for example. Maybe it could be enabled with an option. But that might not play nicely with various jinja Loaders.
I noticed when using
include
with pyjade 2.0.3 with Flask (Jinja2), the path that's specified needs to be relative to the Jinja templates directory. When using the same templates under Jade, those include paths are instead relative to the directory of the template performing the include.Here's an example where I have a task list template that should include task detail as well as user list templates.
templates/tasks/list.jade
:templates/tasks/detail.jade
:templates/users/list.jade
:This is frustrating because I would like to use the
jade
npm module to validate the syntax of my templates, but because theinclude
behavior differs between the two implementations,jade
chokes on things that are valid to PyJade and vice-versa.