There are scenarios where some flask extension might want to provide Flask-Menu capabilities for its blueprints, but the user of the extension is not interested in this (e.g. if the application doesn't have any UI views, but only provides a REST API).
It should be possible to conditionally register the menu item, by checking if current_menu exists before performing the registration:
# inside register_menu
...
@before_first_request
def _register_menu_item():
if current_menu:
item = current_menu.submenu(str(path))
item.register(...)
return f
...
There are scenarios where some flask extension might want to provide
Flask-Menu
capabilities for its blueprints, but the user of the extension is not interested in this (e.g. if the application doesn't have any UI views, but only provides a REST API).It should be possible to conditionally register the menu item, by checking if
current_menu
exists before performing the registration: