Documentation on template tag render() methods is inconsistent with core tags.
|Reported by:||Owned by:||nobody|
|Cc:||Daniele Procida||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
According to the documentation:
render() should never raise TemplateSyntaxError or any other exception. It should fail silently, just as template filters should.
As I write this, at a glance, URLNode.render(), WidthRatio.render(), both raise TemplateSyntaxError. So do some of those outside defaulttags, such as CacheNode.render(), and it looks like ExtendsNode.get_parent() does too (ForLoopNode.render() does, but is exempted from this list because it explicitly only does so if TEMPLATE_DEBUG is True)
I'm marking this as a documentation issue, as I think the wording should be changed to reflect that ideally template tags should fail silently [at least in production, where DEBUG and TEMPLATE_DEBUG should be False], but it is understandable that sometimes they cannot, which is I assume why Django hasn't "dogfooded" it's own advice here.
The links above should all be to the files/documentation as they stand when writing this, pinned to 1.6 or the last commit for temporal accuracy going forwards.
Change History (7)
comment:1 Changed 3 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|
|Type:||Uncategorized → Cleanup/optimization|