Module

rendering.template_engine.menu

Menu helper functions for template engine.

Provides menu access functions with caching for template use.

Related Modules:

  • bengal.rendering.template_engine.core: Uses these helpers
  • bengal.core.menu: Menu data model

Classes

MenuHelpersMixin
Mixin providing menu helper methods for TemplateEngine. Requires these attributes on the host clas…
3

Mixin providing menu helper methods for TemplateEngine.

Requires these attributes on the host class:

  • site: Site instance
  • _menu_dict_cache: dict[str, list[dict]]

Attributes

Name Type Description
site Any
_menu_dict_cache dict[str, list[dict[str, Any]]]

Methods 1

invalidate_menu_cache
Invalidate the menu dict cache. Call this after menus are rebuilt to ensure fr…
0 None
def invalidate_menu_cache(self) -> None

Invalidate the menu dict cache.

Call this after menus are rebuilt to ensure fresh dicts are generated.

Internal Methods 2
_get_menu
Get menu items as dicts for template access (cached).
1 list[dict[str, Any]]
def _get_menu(self, menu_name: str = 'main') -> list[dict[str, Any]]

Get menu items as dicts for template access (cached).

Parameters 1
menu_name str

Name of the menu to get (e.g., 'main', 'footer')

Returns

list[dict[str, Any]]

List of menu item dicts

Performance:

Menu dicts are cached to avoid repeated to_dict() calls on every
page render. Cache is invalidated when menus are rebuilt.

_get_menu_lang
Get menu items for a specific language (cached).
2 list[dict[str, Any]]
def _get_menu_lang(self, menu_name: str = 'main', lang: str = '') -> list[dict[str, Any]]

Get menu items for a specific language (cached).

Parameters 2
menu_name str

Name of the menu to get

lang str

Language code

Returns

list[dict[str, Any]]

List of menu item dicts for the specified language