inveniosoftware / inveniosoftware/flask-menu

global: check for extension initialization in "register_menu"

Open
#65 0 comments 0 reactions 0 assignees View on GitHub
Size: easy Type: enhancement
Dominant language
Python
Stars
54
Forks
43
PR merge metrics
No merged PRs in 30d

Description

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:

```python
# inside register_menu
...
@before_first_request
def _register_menu_item():
if current_menu:
item = current_menu.submenu(str(path))
item.register(...)
return f
...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.