allow conditional templates, although no compilation, thanks Anthony

This commit is contained in:
mdipierro authored and Michele Comitini committed 2013-08-30 17:38:50 +02:00
1 parent c997192277
commit 03942ba38f
2 files changed
+7 -2

No files matched your search

+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
@@ -435,6 +435,10 @@ class TemplateParser(object):
# We need to eval to remove the quotes and get the string type. # We need to eval to remove the quotes and get the string type.
filename = eval(filename, context) 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. # Get the path of the file on the system.
filepath = self.path and os.path.join(self.path, filename) or filename 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 Extend ``filename``. Anything not declared in a block defined by the
parent will be placed in the parent templates ``{{include}}`` block. 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 # Create out nodes list to send to the parent
super_nodes = [] super_nodes = []