summaryrefslogtreecommitdiff
path: root/repoze/bfg/template.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-08-16 09:10:09 +0000
committerChris McDonough <chrism@agendaless.com>2008-08-16 09:10:09 +0000
commit29b888c68c7d4c6a18627f09bcd5db865bcbcaef (patch)
tree9fe25724835fdfbf6323d42573e9783a369bed34 /repoze/bfg/template.py
parent6fd7d0a06b2ec0153765c9f25d7e7f4892683373 (diff)
downloadpyramid-29b888c68c7d4c6a18627f09bcd5db865bcbcaef.tar.gz
pyramid-29b888c68c7d4c6a18627f09bcd5db865bcbcaef.tar.bz2
pyramid-29b888c68c7d4c6a18627f09bcd5db865bcbcaef.zip
Add "get_template" to template module.
Diffstat (limited to 'repoze/bfg/template.py')
-rw-r--r--repoze/bfg/template.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/repoze/bfg/template.py b/repoze/bfg/template.py
index 0d390fecf..3c60dd19e 100644
--- a/repoze/bfg/template.py
+++ b/repoze/bfg/template.py
@@ -67,13 +67,8 @@ def registerTemplate(type, template, path):
else:
sm.registerUtility(template, type, name=path)
-def render_template(path, **kw):
- """ Render a z3c.pt (ZPT) template at the package-relative path
- (may also be absolute) using the kwargs in ``*kw`` as top-level
- names and return a string. """
+def _get_template(path, **kw):
# XXX use pkg_resources
- path = caller_path(path)
-
template = queryUtility(ITemplate, path)
if template is None:
@@ -82,6 +77,20 @@ def render_template(path, **kw):
template = Z3CPTTemplateFactory(path)
registerTemplate(ITemplate, template, path)
+ return template
+
+def get_template(path):
+ """ Return a z3c.pt template object at the package-relative path
+ (may also be absolute) """
+ path = caller_path(path)
+ return _get_template(path).template
+
+def render_template(path, **kw):
+ """ Render a z3c.pt (ZPT) template at the package-relative path
+ (may also be absolute) using the kwargs in ``*kw`` as top-level
+ names and return a string. """
+ path = caller_path(path)
+ template = get_template(path)
return template(**kw)
def render_template_to_response(path, **kw):