Fixed documentation from [4558] to be correct.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4559 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
36512d5d73
commit
a01f852d2e
|
@ -657,12 +657,14 @@ will use the function's name as the filter name.
|
||||||
Template filters which expect strings
|
Template filters which expect strings
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
If you are writing a template filter which only expects a string as the first
|
If you are writing a template filter which only expects a string as the first
|
||||||
argument, you should use the included decorator ``to_str`` which will convert
|
argument, you should use the included decorator ``stringfilter`` which will convert
|
||||||
an object to it's string value before being passed to your function::
|
an object to it's string value before being passed to your function::
|
||||||
|
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
@template.stringfilter
|
||||||
def lower(value):
|
def lower(value):
|
||||||
return value.lower()
|
return value.lower()
|
||||||
lower = template.to_str(lower)
|
|
||||||
|
|
||||||
Writing custom template tags
|
Writing custom template tags
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
Loading…
Reference in New Issue