You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case .j2 files in another package will not be found because the name='.jinja2' by default on the add_jinja2_search_path function.
Expected Behavior
The add_jinja2_renderer will "register" into the Pyramid renderer system that .j2 files should always be rendered using Jinja2, regardless of the package / search path.
The state of the .j2 registration would be captured and used in other functions/methods.
Actual Behavior
The add_jinja2_renderer function / method only registers .j2 files for the default search path, any additional search paths need to pass the extension name.
That's not a workaround - that's the intended solution. pyramid_jinja2 allows you to define separate rendering systems for various file types. It is all documented this way. For example in add_jinja2_search_path: It will add the directory or :term:`asset specification` passed as ``searchpath`` to the current search path of the :class:`jinja2.Environment` used by the renderer identified by ``name``.
An option that has come up before but no one has implemented yet is something like add_jinja2_renderer('.j2', alias='.jinja2') or something like that. Alternatively we could just change the semantics such that renderers defined from the same settings namespace share the same environment - I would be ok with this change as well.
Background
If
mypackage/__init__.py
adds a jinja renderer with a customname
value, only the directorymypackage/templates
is searched.For example:
In this case
.j2
files in another package will not be found because thename='.jinja2'
by default on theadd_jinja2_search_path
function.Expected Behavior
The
add_jinja2_renderer
will "register" into the Pyramid renderer system that.j2
files should always be rendered using Jinja2, regardless of the package / search path.The state of the
.j2
registration would be captured and used in other functions/methods.Actual Behavior
The
add_jinja2_renderer
function / method only registers.j2
files for the default search path, any additional search paths need to pass the extensionname
.Work around
The text was updated successfully, but these errors were encountered: