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

Unified Diff: README.md

Issue 5521995252891648: Issue 2180 - [cms] Add support for custom Jinja2 functions (Closed)
Patch Set: Better comment Created March 20, 2015, 4:42 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/converters.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: README.md
===================================================================
--- a/README.md
+++ b/README.md
@@ -71,16 +71,17 @@ Here `www_directory` should be replaced
`target_directory` is the path where static files will be placed..
## Content structure ##
Currently, the following directories of your content directory will be
considered:
* `filters`: Custom Jinja2 filters
+* `globals`: Custom Jinja2 global functions and variables
* `includes`: Various include files
* `locales`: Localization files
* `pages`: User-visible pages
* `static`: Static content
* `templates`: Page layout templates
There should also be a `settings.ini` file with configuration.
@@ -232,12 +233,20 @@ The differences to pages using the same
By default, `default.tmpl` will be used for all pages. If other templates are
defined, the pages need to choose them explicitly using the `template` setting.
### Custom filters ###
The `filters` directory can define custom Jinja2 filters which will be available
in all Jinja2 templates. The file name defines the filter name, e.g.
-`myfilter.py` will define a filter named `myfilter`. This file should also
-contain a function called `myfilter`, this one will be called when the filter is
-invoked. For more information on Jinja2 filters see
+`filters/myfilter.py` will define a filter named `myfilter`. This file should
+also contain a function called `myfilter`, this one will be called when the
+filter is invoked. For more information on Jinja2 filters see
[official documentation](http://jinja.pocoo.org/docs/dev/api/#writing-filters).
+
+### Custom functions and variables ###
+
+The `globals` directory can define custom Jinja2 globals which will be available
+in all Jinja2 templates. Typically, this is used for custom functions. The file
+name should match the name of the function or variable to be defined, and export
+a variable with that name. E.g. `globals/myfunction.py` can define a function
+called `myfunction` that will become available to all Jinja2 templates.
« no previous file with comments | « no previous file | cms/converters.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld