dj111
eric 2018-07-24 12:06:38 -04:00
parent fed891f6a7
commit 8c3b630eb6
1 changed files with 5 additions and 2 deletions

View File

@ -1,14 +1,17 @@
import django.template
from django.template import Template
from django.template.engine import Engine
register = django.template.Library()
engine = Engine.get_default()
@register.simple_tag(takes_context=True)
def render_with_landing(context, text):
if not context.has_key('landing_object') and context.has_key('runinfo'):
landing = context['runinfo'].landing
context['landing_object'] = landing.content_object if landing else ''
if text:
template = Template(text, using='DjangoTemplates')
template = engine.from_string(text)
return template.render(context)
else: