Embedding views in templates
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I think there is a common need to use reuse logic-backed data in multiple places (e.g. latest comments box in a blogging app)
A well-known solution among django community is use of
templatetags: (e.g. QA1, QA2)
But regarding the NIH-syndrome I don't think it would be a good idea to invent yet-another-templatetag for each embedded view, which I've already seen it in many projects.
I suppose having a
render_view templatetag in core would both increase code reuse and readability. See Symfony2 for an equivalent approach.
The implementation would be pretty straightforward, with a new
simple_tag forwarding calls to appropriate view. A bonus would be the ability provide ajax-based partial contents.