Module

rendering.template_engine.url_helpers

URL generation helpers for template engine.

Provides URL generation functions for pages and assets with baseurl support.

Related Modules:

  • bengal.rendering.template_engine.core: Uses these helpers

Functions

url_for
Generate URL for a page with base URL support.
2 str
def url_for(page: Page | Mapping[str, Any] | Any, site: Site) -> str

Generate URL for a page with base URL support.

Parameters 2

Name Type Default Description
page Page | Mapping[str, Any] | Any

Page object

site Site

Site instance

Returns

str

URL path (clean, without index.html) with base URL prefix if configured

with_baseurl
Apply base URL prefix to a path.
2 str
def with_baseurl(path: str, site: Site) -> str

Apply base URL prefix to a path.

Parameters 2

Name Type Default Description
path str

Relative path starting with '/'

site Site

Site instance

Returns

str

Path with base URL prefix (absolute or path-only)

filter_dateformat
Format a date using strftime.
2 str
def filter_dateformat(date: datetime | str | None, format: str = '%Y-%m-%d') -> str

Format a date using strftime.

Parameters 2

Name Type Default Description
date datetime | str | None

Date to format

format str '%Y-%m-%d'

strftime format string

Returns

str

Formatted date string