bundle.website.core.templating¶
Template path discovery and shared context helpers for website pages.
Classes¶
Derive page boilerplate (router, templates, logger, paths) from a module file. |
Functions¶
|
Resolve the page-local template folder for the given module file. |
|
Resolve the page-local static folder for the given module file. |
|
Return a namespaced logger for website page/component modules. |
|
Create a Jinja environment that can resolve page templates and shared layouts. |
|
Build the shared template context for website pages. |
Module Contents¶
- bundle.website.core.templating.get_template_path(file_path: str | pathlib.Path) pathlib.Path¶
Resolve the page-local template folder for the given module file.
- bundle.website.core.templating.get_static_path(file_path: str | pathlib.Path) pathlib.Path¶
Resolve the page-local static folder for the given module file.
- bundle.website.core.templating.get_logger(page_name: str) logging.Logger¶
Return a namespaced logger for website page/component modules.
- bundle.website.core.templating.create_templates(*template_roots: collections.abc.Iterable[pathlib.Path | str] | pathlib.Path | str) fastapi.templating.Jinja2Templates¶
Create a Jinja environment that can resolve page templates and shared layouts.
The shared base template and component template roots are always appended.
- bundle.website.core.templating.base_context(request: Any, extra: collections.abc.Mapping[str, Any] | None = None) dict[str, Any]¶
Build the shared template context for website pages.
- class bundle.website.core.templating.PageModule(module_file: str | pathlib.Path, name: str, *, slug: str | None = None, href: str | None = None, description: str = '', show_in_nav: bool = True, show_on_home: bool = True)¶
Derive page boilerplate (router, templates, logger, paths) from a module file.
Holds both runtime objects (router, templates, logger) and page metadata (name, slug, href, description) so each page declares everything in one place.
- name¶
- slug¶
- href¶
- description = ''¶
- show_on_home = True¶
- template_path¶
- static_path¶
- logger¶
- router¶
- templates¶