from django import template

register = template.Library()

@register.filter
def render_markup(string, markup_lang=None):
    from django.contrib.markup.templatetags import markup
    if markup_lang:
        markup_lang = markup_lang.lower()
        try:
            return getattr(markup, markup_lang)(string)
        except AttributeError:
            raise ValueError("Markup filter %r not found." % markup_lang)
    return string