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

Unified Diff: README.md

Issue 29328184: Issue 3092 - Support use of Jinja2 template inheritance (Closed)
Patch Set: Created Sept. 18, 2015, 11:06 a.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/converters.py » ('j') | cms/converters.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: README.md
diff --git a/README.md b/README.md
index c7d2cb182d5d3171a553c1f50ef599bf5f7f3289..38068a7d2b8055c50539219ed4a0d668845378ca 100644
--- a/README.md
+++ b/README.md
@@ -250,9 +250,34 @@ Markdown.
Complicated pages can be defined using the
[Jinja2 template format](http://jinja.pocoo.org/docs/templates/). Automatic
escaping is active so by default values inserted into the page cannot contain
-any HTML code. Any content between `<head>` and `</head>` tags will be inserted
-into the head of the generated web page, everything else defined the content of
-the page.
+any HTML code.
+
+For Jinja2 pages that make use of the `{% extends ... %}` tag, template
+inheritance is left to Jinja2. It is expected you will populate blocks like
+`body` and `head` manually from those pages and have the corresponding blocks in
+the parent template.
+
+If a Jinja2 page does not contain an `{% extends ... %}` tag however the CMS
+will take care of template inheritance as with the other formats. The template
+as specified in the `template` option will be used by the CMS. Anything between
+the `<head>` and `</head>` tags will be inserted into a `head` variable, the
+rest into a `body` variable.
+
+_Note: if you do not use the {% extends ... %} tag the parent template will not
+have access to any of the page's state. Blocks, variables etc defined in the
+page will not be available for use from the template._
+
+If you would like your template to support both Jinja2 and standard template
+inheritance it is recommended to follow this pattern:
+
+ ...
+ {% block head %}
+ {% head|safe %}
+ {% endblock %}
+ ...
+ {% block body %}
+ {% body|safe %}
+ {% endblock %}
The following variables can be used:
« no previous file with comments | « no previous file | cms/converters.py » ('j') | cms/converters.py » ('J')

Powered by Google App Engine
This is Rietveld