Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/converters.py

Issue 4923768585584640: Issue 2179 - [cms] Give Jinja2 templates a way to set global parameters (Closed)
Patch Set: Created March 19, 2015, 9:29 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/converters.py
===================================================================
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -289,17 +289,17 @@ class TemplateConverter(Converter):
extensions=["jinja2.ext.do",],
autoescape=True
)
self._env.filters.update(filters)
self._env.globals.update(globals)
def get_html(self, source):
template = self._env.from_string(source)
- return template.render(self._params)
+ return template.render(self._params, params=self._params)
Sebastian Noack 2015/03/20 09:44:36 Note that modifying the params dict won't modify t
Wladimir Palant 2015/03/20 15:31:39 The complication here: only variables set at top l
Sebastian Noack 2015/03/20 15:53:18 I think it's the best we can realistically do.
def translate(self, default, name, comment=None):
# Note: We currently ignore the comment, it is only relevant when
# generating the master translation.
localedata = self._params["localedata"]
return jinja2.Markup(self.localize_string(name, default, localedata, html_escapes))
def get_string(self, name, page):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld