@register.tag def head_include(parser, token): nodelist = parser.parse(('endhead_include',)) parser.delete_first_token() return HeadBlock(nodelist) class HeadBlock(template.Node): def __init__(self, nodelist): self.nodelist = nodelist def render(self, context): output = self.nodelist.render(context) addcategory("header", "%s\n" % (output)) return None