Skip to content

Instantly share code, notes, and snippets.

@oscarmcm
Created May 22, 2015 22:13
Show Gist options
  • Save oscarmcm/6f243adabc7ea3687266 to your computer and use it in GitHub Desktop.
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
# -*- 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