allow conditional templates, although no compilation, thanks Anthony

This commit is contained in:
mdipierro
2013-08-30 17:38:50 +02:00
committed by Michele Comitini
parent c997192277
commit 03942ba38f
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.6.0-development+timestamp.2013.08.27.16.11.32
Version 2.6.0-development+timestamp.2013.08.27.16.17.15
+6 -1
View File
@@ -434,6 +434,10 @@ class TemplateParser(object):
# Get the filename; filename looks like ``"template.html"``.
# We need to eval to remove the quotes and get the string type.
filename = eval(filename, context)
# Allow empty filename for conditional extend and include directives.
if not filename:
return ''
# Get the path of the file on the system.
filepath = self.path and os.path.join(self.path, filename) or filename
@@ -468,7 +472,8 @@ class TemplateParser(object):
Extend ``filename``. Anything not declared in a block defined by the
parent will be placed in the parent templates ``{{include}}`` block.
"""
text = self._get_file_text(filename)
# If no filename, create a dummy layout with only an {{include}}.
text = self._get_file_text(filename) or '%sinclude%s' % tuple(self.delimiters)
# Create out nodes list to send to the parent
super_nodes = []