Created
August 8, 2012 20:37
-
-
Save mgerring/3298484 to your computer and use it in GitHub Desktop.
Django "replace" filter
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.defaultfilters import stringfilter | |
register = template.Library() | |
@register.filter | |
@stringfilter | |
def replace(value, arg): | |
args = arg.split(',') | |
return value.replace(args[0], args[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment