bittersweet.templatetags.bittersweet_render_inline module

Render a template variable as Django template source in the current context

class bittersweet.templatetags.bittersweet_render_inline.RenderInlineNode(nodelist)[source]

Bases: django.template.base.Node

render(context)[source]
bittersweet.templatetags.bittersweet_render_inline.render_inline(parser, token)[source]

A template tag which renders its contents as a template using the current context, allowing you to process template code stored in something like gettext blocks, model content, django-flatblocks, etc. as if it was actually in the current template.

Usage:

my_template.html:

{% render_inline %}
<b>{{ VARIABLE_WHICH_CONTAINS_TEMPLATE_MARKUP }}</b>
{% end_render_inline %}

Context:

{'VARIABLE_WHICH_CONTAINS_TEMPLATE_MARKUP': 'Hello {{ CURRENT_USER.name }}'}

Output:

'<b>Hello J. Random User</b>'