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

Side by Side Diff: sitescripts/utils.py

Issue 6439145228468224: Added custom template loader to CMS in order to enable {% include %} and {% import %} in jinja temp… (Closed)
Patch Set: Adressed comments Created Dec. 12, 2013, 12:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« sitescripts/cms/converters.py ('K') | « sitescripts/cms/converters.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 """ 135 """
136 Returns a Jinja2 template environment without autoescaping. Don't use this t o 136 Returns a Jinja2 template environment without autoescaping. Don't use this t o
137 generate HTML files! 137 generate HTML files!
138 """ 138 """
139 from sitescripts.templateFilters import filters 139 from sitescripts.templateFilters import filters
140 import jinja2 140 import jinja2
141 env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath)) 141 env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath))
142 env.filters.update(filters) 142 env.filters.update(filters)
143 return env 143 return env
144 144
145 def get_custom_template_environment(additional_filters): 145 def get_custom_template_environment(additional_filters, loader=None):
146 """ 146 """
147 Returns a custom Jinja2 template environment with additional filters. 147 Returns a custom Jinja2 template environment with additional filters.
148 """ 148 """
149 from sitescripts.templateFilters import filters 149 from sitescripts.templateFilters import filters
150 import jinja2 150 import jinja2
151 env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath), auto escape=True) 151 if not loader:
152 loader = jinja2.FileSystemLoader(siteScriptsPath)
153 env = jinja2.Environment(loader=loader, autoescape=True)
152 env.filters.update(filters) 154 env.filters.update(filters)
153 env.filters.update(additional_filters) 155 env.filters.update(additional_filters)
154 return env 156 return env
OLDNEW
« sitescripts/cms/converters.py ('K') | « sitescripts/cms/converters.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld