+
+ if not container_content:
+ return ''
+
+ return container_content
+
+ 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 '{%' in contentlet.content or '{{' in contentlet.content:
+ try:
+ 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 = settings.TEMPLATE_STRING_IF_INVALID
+ content = mark_safe(content)