Documentation on template tag render() methods is inconsistent with core tags.
|Reported by:||Keryn Knight <django@…>||Owned by:||nobody|
|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 23 months ago by timo
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Uncategorized to Cleanup/optimization
comment:5 Changed 21 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from new to closed