-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template filters now pass numerical arguments through as numbers.
This was the (undocumented) behaviour prior to r10118 and now it's back again. It's neither hard nor harmful to maintain compatibility with the old ways. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10169 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
Showing
5 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django import test | ||
from django import template | ||
|
||
|
||
custom_filters = """ | ||
>>> t = template.Template("{% load custom %}{{ string|trim:5 }}") | ||
>>> ctxt = template.Context({"string": "abcdefghijklmnopqrstuvwxyz"}) | ||
>>> t.render(ctxt) | ||
u"abcde" | ||
""" | ||
|
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django import template | ||
from django.template.defaultfilters import stringfilter | ||
|
||
register = template.Library() | ||
|
||
def trim(value, num): | ||
return value[:num] | ||
trim = stringfilter(trim) | ||
|
||
register.filter(trim) | ||
|
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