Alice wrote: > thanks :) > > did anything ever come of it? > > I agree that if a clean implementation cannot be done, it shouldn't. > There was another interesting idea that a block could be referenced as > a variable > > {% block content %} > {% endblock %} > > {{ content }} > > or perhaps > > {{ __content__ }} > > any feedback on this? > > > Alice > >
Anything which you want to be able to include in multiple places and contains logic is best done as a template tag. A good way to do your particular task may be to use the @inclusion_tag decorator in ticket #625 ( see below), but you can also do it the long way as in http://www.djangoproject.com/documentation/templates_python/ Under the section 'Writing custom template tags' . So to do it using the inclusion_tag decorator, assuming a few random things to make it interesting: in your templatetags module: from django.core.template_decorators import inclusion_tag @inclusion_tag('my_app/menu') def main_menu(user): return { 'items' : get_standard_items() + get_items_for_user(user) } in the template 'my_app/menu': <ul class="menu"> {for item in items} <li>{{item}}</li> {endfor} </ul> to use it: {% load mytemplates %} {% main_menu user %} where user is a variable holding your user object. If you don't have any logic in there, maybe the include tag in #598 would be a good fit. {% include "my_app/menu" %} Robert