Created
September 15, 2010 18:55
-
-
Save adamn/581230 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.defaultfilters import stringfilter | |
register = template.Library() | |
@register.filter(name='prepend') | |
@stringfilter | |
def prepend(value, arg): | |
""" | |
Prepends value with arg if value exists, else returns '' | |
""" | |
return '%s%s' % (arg, value) if value else '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment