Created
January 7, 2011 18:28
-
-
Save jacobian/769872 to your computer and use it in GitHub Desktop.
This file contains 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
from django import template | |
from django.template import defaulttags | |
from django.utils.safestring import mark_for_escaping | |
register = template.Library() | |
class EscapedNode(template.Node): | |
def __init__(self, node): | |
self.node = node | |
def render(self, context): | |
return mark_for_escaping(self.node.render(context)) | |
@register.tag | |
def firstof(parser, token): | |
node = defaulttags.firstof(parser, token) | |
return EscapedNode(node) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment