Fixed a bug where the ContainerNode had a nodelist_empty=None, whereas nodelist_empty...
authormelinath <stephen.r.burrows@gmail.com>
Wed, 9 Jun 2010 21:46:48 +0000 (17:46 -0400)
committermelinath <stephen.r.burrows@gmail.com>
Wed, 9 Jun 2010 21:51:30 +0000 (17:51 -0400)
models.py
templatetags/containers.py

index b1da9d0..dcb5d74 100644 (file)
--- a/models.py
+++ b/models.py
@@ -311,7 +311,7 @@ class Template(TreeModel):
                                nodes = []
                                for node in nodelist:
                                        try:
-                                               for nodelist_name in ('nodelist', 'nodelist_loop', 'nodelist_empty', 'nodelist_true', 'nodelist_false'):
+                                               for nodelist_name in ('nodelist', 'nodelist_loop', 'nodelist_empty', 'nodelist_true', 'nodelist_false', 'nodelist_main'):
                                                        if hasattr(node, nodelist_name):
                                                                nodes.extend(nodelist_container_nodes(getattr(node, nodelist_name)))
                                                if isinstance(node, ContainerNode):
index 45a9965..ac43256 100644 (file)
@@ -9,12 +9,22 @@ register = template.Library()
 
 
 class ContainerNode(template.Node):
+       child_nodelists = ('nodelist_main', 'nodelist_empty',)
+       
        def __init__(self, name, references=None, as_var=None, nodelist_main=None, nodelist_empty=None):
                self.name = name
                self.as_var = as_var
                self.references = references
-               self.nodelist_main = nodelist_main
-               self.nodelist_empty = nodelist_empty
+               
+               if nodelist_main is None:
+                       self.nodelist_main = template.NodeList()
+               else:
+                       self.nodelist_main = nodelist_main
+               
+               if nodelist_empty is None:
+                       self.nodelist_empty = template.NodeList()
+               else:
+                       self.nodelist_empty = nodelist_empty
                
        def render(self, context):
                content = settings.TEMPLATE_STRING_IF_INVALID
@@ -22,6 +32,7 @@ class ContainerNode(template.Node):
                        container_content = self.get_container_content(context['page'])
                
                if self.nodelist_main is None:
+                       self.nodelist_main
                        if container_content and self.as_var:
                                context[self.as_var] = container_content
                                return ''
@@ -108,4 +119,5 @@ def do_container(parser, token):
                
        else: # error
                raise template.TemplateSyntaxError('"%s" template tag provided without arguments (at least one required)' % tag)
-register.tag('container', do_container)
\ No newline at end of file
+register.tag('container', do_container)
+register.tag('blockcontainer', do_container)
\ No newline at end of file