Created
May 22, 2015 22:13
-
-
Save oscarmcm/6f243adabc7ea3687266 to your computer and use it in GitHub Desktop.
Simple Django Template Tag that render another template tag added in a text field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django import template | |
from django.template.context import Context | |
from django.template.defaultfilters import stringfilter | |
from django.template.loader import get_template_from_string | |
register = template.Library() | |
@register.filter | |
@stringfilter | |
def render_chart(value): | |
""" | |
You can use this | |
{{message.body|render}} | |
""" | |
return get_template_from_string(value).render(Context()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment