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

Unified Diff: sitescripts/utils.py

Issue 11481051: Update stats processing (Closed)
Patch Set: Fixed review issues Created Aug. 27, 2013, 7:29 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 | « sitescripts/templateFilters.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/utils.py
===================================================================
--- a/sitescripts/utils.py
+++ b/sitescripts/utils.py
@@ -114,30 +114,41 @@ def get_template(template, autoescape=Tr
if not key in _template_cache:
if autoescape:
env = get_template_environment()
else:
env = get_unescaped_template_environment()
_template_cache[key] = env.get_template(template)
return _template_cache[key]
-@cached(())
+@cached(float("inf"))
def get_template_environment():
"""
Returns a Jinja2 template environment with autoescaping enabled.
"""
from sitescripts.templateFilters import filters
import jinja2
- env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath), autoescape=True, extensions=['jinja2.ext.autoescape'])
+ env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath), autoescape=True)
env.filters.update(filters)
return env
-@cached(())
+@cached(float("inf"))
def get_unescaped_template_environment():
"""
Returns a Jinja2 template environment without autoescaping. Don't use this to
generate HTML files!
"""
from sitescripts.templateFilters import filters
import jinja2
env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath))
env.filters.update(filters)
return env
+
+def get_custom_template_environment(additional_filters):
+ """
+ Returns a custom Jinja2 template environment with additional filters.
+ """
+ from sitescripts.templateFilters import filters
+ import jinja2
+ env = jinja2.Environment(loader=jinja2.FileSystemLoader(siteScriptsPath), autoescape=True)
+ env.filters.update(filters)
+ env.filters.update(additional_filters)
+ return env
« no previous file with comments | « sitescripts/templateFilters.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld