On Tue, May 3, 2011 at 1:29 PM, MikeKJ <mike.jo...@paston.co.uk> wrote:
>
>
> In this instance the else is active as there is no incoming context
>
>
> def get_pretty_smartpage_for_email(slug, context=None,
> surrounding_template='email/pretty.html'):
>    """
>    Renders a smartpage using the 'pretty' email template
>    returns the rendered content, with any passed-in context rendered in
>    """
>
>    try:
>        s = SmartPage.objects.get(slug=slug)
>    except SmartPage.DoesNotExist:
>        s = SmartPage(content='Error: Missing template: %s' % slug,
> name='Missing template')
>
>    if context:
>        # Render any passed-in context into the smartpage
>        sptemplate = loader.get_template_from_string(s.content)
>        spcontent = sptemplate.render(context)
>    else:
>        spcontent = s.content
>        if slug == 'email-policy-summary' or 'fleet-email-policy-summary':
>                spcontent = '
> http://lime.paston.co.uk/media/images/Keyfacts_logo_.jpg ' + spcontent
>
>    context = Context({
>        'content' : spcontent,
>        'title' : s.name,
>    })
>
>    t = loader.get_template(surrounding_template)
>    content = t.render(context)
>

spcontent is HTML?

    from django.utils.safestring import mark_safe
    context = Context({
        'content' : mark_safe(spcontent),
        'title' : s.name,
    })

http://docs.djangoproject.com/en/1.3/ref/utils/#django.utils.safestring.mark_safe
http://docs.djangoproject.com/en/1.3/howto/custom-template-tags/#filters-and-auto-escaping

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to