Skip to content
Snippets Groups Projects
Commit dfac9164 authored by Thomas Schneider's avatar Thomas Schneider
Browse files

helpers: Blueprint.render_template: factor out real_template_name()

parent a687076b
No related branches found
No related tags found
No related merge requests found
...@@ -6,10 +6,8 @@ from jinja2 import BaseLoader, ChoiceLoader, PrefixLoader, Template ...@@ -6,10 +6,8 @@ from jinja2 import BaseLoader, ChoiceLoader, PrefixLoader, Template
class Blueprint(FlaskBlueprint): class Blueprint(FlaskBlueprint):
def render_template( def real_template_name(
self, self, template: str | Template | list[str | Template]
template: str | Template | list[str | Template],
**context: t.Any,
) -> str: ) -> str:
if self.jinja_loader is not None: if self.jinja_loader is not None:
# XXX This currently assumes ":" as PrefixLoader.delimiter in the app # XXX This currently assumes ":" as PrefixLoader.delimiter in the app
...@@ -19,6 +17,14 @@ class Blueprint(FlaskBlueprint): ...@@ -19,6 +17,14 @@ class Blueprint(FlaskBlueprint):
for i, tpl in enumerate(template): for i, tpl in enumerate(template):
if isinstance(t, str) and ":" not in tpl: if isinstance(t, str) and ":" not in tpl:
template[i] = self.name + ":" + tpl template[i] = self.name + ":" + tpl
return template
def render_template(
self,
template: str | Template | list[str | Template],
**context: t.Any,
) -> str:
template = self.real_template_name(template)
return render_template(template, **context) return render_template(template, **context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment