Inside main template: {% block step_1 %} {% with wizard.step_1 as step %} {% decorate "item/wizard/ajax_step_decorator.html" %} {% localblock step_ready_js %} $(this).standardWizardStepFormBind(step, formId); {% endlocalblock %} {% enddecorate %} {% endwith %} {% endblock %} {% block step_2 %} {% with wizard.step_2 as step %} {% decorate "item/wizard/ajax_step_decorator.html" %} {% localblock step_ready_js %} $(this).categorySelectLiveQueryActions(); {% endlocalblock %} {% enddecorate %} {% endwith %} {% endblock %} Decorator: item/wizard/ajax_step_decorator.html {% load conversation %} {% load common_webdesign %}
Implementation (templatetags): def decorate(parser, token): nodelist = parser.parse(('enddecorate',)) parser.delete_first_token() try: tag_name, template_name = token.split_contents() except ValueError: raise TemplateSyntaxError, "%r tag requires one argument" % \ token.contents.split()[0] decorateNode = DecorateNode(nodelist, parser.compile_filter(template_name)) return decorateNode class DecorateNode(Node): def __init__(self, nodelist, template_name): self.nodelist = nodelist self.template_name = template_name self.blocks = dict([(n.name, n) for n in nodelist.get_nodes_by_type(LocalBlockNode)]) def render(self, context): template_name = self.template_name.resolve(context) t = get_template(template_name) context['localblock'] = self.blocks return t.render(context) class LocalBlockNode(Node): def __init__(self, name, nodelist, parent=None): self.name, self.nodelist, self.parent = name, nodelist, parent def __repr__(self): return "