summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2014-04-09 23:19:55 -0600
committerTim Graham <timograham@gmail.com>2014-04-10 06:19:15 -0400
commit728fd27c005e98868a3be74949f306038e30e427 (patch)
treee50595b9c17d9d1191f39edcc292c6785626bbe5 /docs/howto
parente68c084ed17d185f19658e1d7fe8c7047d59aea6 (diff)
[1.6.x] Fixed #22412 -- More nuanced advice re template filters and exceptions.
Thanks Tim for review. Backport of 7e3834adc9 from master
Diffstat (limited to 'docs/howto')
-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 527af3fd8c..8ad7624bea 100644
--- a/docs/howto/custom-template-tags.txt
+++ b/docs/howto/custom-template-tags.txt
@@ -87,9 +87,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: