Using Jinja2 contextfunction like django inclusion tag -
i trying add contextfunction rendering menu html, jinja2 environment globals.
i have written:
@contextfunction def main_menu(context, parent, calling_page=none): menuitems = parent.get_children().live().in_menu() menuitem in menuitems: menuitem.show_dropdown = has_menu_children(menuitem) # don't directly check if calling_page none since template # engine can pass empty string calling_page # if variable passed calling_page not exist. menuitem.active = (calling_page.path.startswith(menuitem.path) if calling_page else false) return render ( context['request'], 'personal_web/tags/main_menu.html', { 'calling_page': calling_page, 'menuitems': menuitems, })
but when use {{ main_menu( parent=site_root, calling_page=self) }}
in template , call function renders ''
what doing wrong?
Comments
Post a Comment