Created
May 14, 2010 20:07
-
-
Save tkaemming/401597 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
import re | |
from django import template | |
register = template.Library() | |
@register.filter | |
def gist(value): | |
gist_regex = re.compile(r'http://gist\.github\.com/(?P<hash>[\d]+)/?') | |
return gist_regex.sub(lambda match: u'<script src="http://gist.github.com/%s.js"></script>' % match.group('hash'), value) | |
gist.is_safe = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment