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

Unified Diff: cms/converters.py

Issue 5148261828526080: Issue 2119 - Add get_page_content template function. (Closed)
Patch Set: Addressed Sebastian's feedback. Created April 5, 2015, 1:24 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 | cms/utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/converters.py
diff --git a/cms/converters.py b/cms/converters.py
index a59bf2ea26728ead3f5bd243e3c80b77b3aeefa5..67d55a081e7cd268a20d3e6e024887958deea5a3 100644
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -292,6 +292,7 @@ class TemplateConverter(Converter):
globals = {
"get_string": self.get_string,
+ "get_page_content": self.get_page_content,
}
for dirname, dictionary in [("filters", filters), ("globals", globals)]:
@@ -342,6 +343,15 @@ class TemplateConverter(Converter):
default = localedata[name]
return jinja2.Markup(self.localize_string(name, default, localedata, html_escapes))
+ def get_page_content(self, page, locale=None):
+ from utils import get_page_params
Wladimir Palant 2015/04/06 19:14:30 That's an implicit relative import. From https://w
kzar 2015/04/07 14:43:56 Done.
+
+ page, ext = os.path.splitext(page)
Wladimir Palant 2015/04/06 19:14:30 We never specify the format as part of the page. Y
kzar 2015/04/07 14:43:56 Done.
+ if locale is None:
+ locale = self._params["locale"]
+ params = get_page_params(self._params["source"], locale, page, ext[1:])
+ return {k: params[k] for k in ("head", "body")}
+
def linkify(self, page, locale=None, **attrs):
if locale is None:
locale = self._params["locale"]
« no previous file with comments | « no previous file | cms/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld