quart-imp/docs/_md/v1/ImpBlueprint-import_nested_blueprints.md
David Carmichael bfcc49dd8d feat: docs
2024-08-16 15:09:07 +01:00

1.4 KiB

Menu = ImpBlueprint/import_nested_blueprints
Title = ImpBlueprint.import_nested_blueprints
import_nested_blueprints(self, folder: str) -> None

Will import all the Blueprints from the given folder relative to the Blueprint's root directory.

Uses Blueprint / import_nested_blueprint to import blueprints from the specified folder.

Blueprints that are imported this way will be scoped to the parent Blueprint that imported them.

url_for('my_blueprint.nested_bp_one.index')

url_for('my_blueprint.nested_bp_two.index')

url_for('my_blueprint.nested_bp_three.index')

my_blueprint/
├── routes/...
├── static/...
├── templates/...
│
├── nested_blueprints/
│   │
│   ├── nested_bp_one/
│   │   ├── ...
│   │   ├── __init__.py
│   ├── nested_bp_two/
│   │   ├── ...
│   │   ├── __init__.py
│   └── nested_bp_three/
│       ├── ...
│       ├── __init__.py
│
├── __init__.py

File: my_blueprint/__init__.py

from quart_imp import ImpBlueprint
from quart_imp.config import ImpBlueprintConfig

bp = ImpBlueprint(__name__, ImpBlueprintConfig(
    enabled=True,
    static_folder="static",
    template_folder="templates",
))

bp.import_resources("routes")
bp.import_nested_blueprints("nested_blueprints")