summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2014-04-09 23:19:55 -0600
committerCarl Meyer <carl@oddbird.net>2014-04-09 23:19:55 -0600
commit7e3834adc993317bc691cc6edc0be13538dc39ad (patch)
treed5d6cc7ac9eedbd52bc59b342ce1a4496df000ae /docs
parent59b1d3098f393f0754b60ebb710450cba9891e6e (diff)
Fixed #22412 -- More nuanced advice re template filters and exceptions.
Thanks Tim for review.
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/custom-template-tags.txt8
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/howto/custom-template-tags.txt b/docs/howto/custom-template-tags.txt
index f07ae6112f..f26fa34af9 100644
--- a/docs/howto/custom-template-tags.txt
+++ b/docs/howto/custom-template-tags.txt
@@ -88,9 +88,11 @@ Custom filters are just Python functions that take one or two arguments:
For example, in the filter ``{{ var|foo:"bar" }}``, the filter ``foo`` would be
passed the variable ``var`` and the argument ``"bar"``.
-Filter functions should always return something. They shouldn't raise
-exceptions. They should fail silently. In case of error, they should return
-either the original input or an empty string -- whichever makes more sense.
+Usually any exception raised from a template filter will be exposed as a server
+error. Thus, filter functions should avoid raising exceptions if there is a
+reasonable fallback value to return. In case of input that represents a clear
+bug in a template, raising an exception may still be better than silent failure
+which hides the bug.
Here's an example filter definition: