Shunted the responsibility in Entity proxy models for setting an Attribute's value...
[philo.git] / templatetags / containers.py
index 92e126e..8bb0c6b 100644 (file)
@@ -18,6 +18,8 @@ class ContainerNode(template.Node):
                content = settings.TEMPLATE_STRING_IF_INVALID
                if 'page' in context:
                        container_content = self.get_container_content(context)
+               else:
+                       container_content = None
                
                if self.as_var:
                        context[self.as_var] = container_content
@@ -31,24 +33,29 @@ class ContainerNode(template.Node):
        def get_container_content(self, context):
                page = context['page']
                if self.references:
+                       # Then it's a content reference.
                        try:
                                contentreference = page.contentreferences.get(name__exact=self.name, content_type=self.references)
                                content = contentreference.content
                        except ObjectDoesNotExist:
                                content = ''
                else:
+                       # Otherwise it's a contentlet.
                        try:
                                contentlet = page.contentlets.get(name__exact=self.name)
-                               if contentlet.dynamic:
+                               if '{%' in contentlet.content:
                                        try:
-                                               content = mark_safe(template.Template(contentlet.content, name=contentlet.name).render(context))
+                                               content = template.Template(contentlet.content, name=contentlet.name).render(context)
                                        except template.TemplateSyntaxError, error:
                                                if settings.DEBUG:
                                                        content = ('[Error parsing contentlet \'%s\': %s]' % (self.name, error))
+                                               else:
+                                                       content = settings.TEMPLATE_STRING_IF_INVALID
                                else:
                                        content = contentlet.content
                        except ObjectDoesNotExist:
-                               content = ''
+                               content = settings.TEMPLATE_STRING_IF_INVALID
+                       content = mark_safe(content)
                return content