Classes
AssetURLMixin
7
▼
Mixin providing asset URL generation for TemplateEngine.
Requires these attributes on the host cla…
AssetURLMixin
7
▼
Mixin providing asset URL generation for TemplateEngine.
Requires these attributes on the host class:
- site: Site instance
- _asset_manifest_path: Path
Requires these methods from ManifestHelpersMixin (must come BEFORE this mixin in MRO):
- _get_manifest_entry(logical_path: str) -> AssetManifestEntry | None
- _warn_manifest_fallback(logical_path: str) -> None
Attributes
| Name | Type | Description |
|---|---|---|
site |
Any
|
— |
_asset_manifest_path |
Path
|
— |
_asset_manifest_present |
bool
|
— |
_fingerprinted_asset_cache |
dict[str, str | None]
|
— |
Methods
Internal Methods 3 ▼
_asset_url
2
str
▼
Generate URL for an asset.
**Handles:**
- Manifest lookup for fingerprinted as…
_asset_url
2
str
▼
def _asset_url(self, asset_path: str, page_context: Any = None) -> str
Generate URL for an asset.
Handles:
- Manifest lookup for fingerprinted assets
- file:// protocol with relative paths
- Dev server mode (no fingerprints)
- Fallback to direct asset paths
Parameters
| Name | Type | Description |
|---|---|---|
asset_path |
— |
Path to asset file |
page_context |
— |
Optional page context for computing relative paths Default:None
|
Returns
str
Asset URL
_asset_url_file_protocol
2
str
▼
Generate asset URL for file:// protocol using relative paths.
_asset_url_file_protocol
2
str
▼
def _asset_url_file_protocol(self, safe_asset_path: str, page_context: Any) -> str
Parameters
| Name | Type | Description |
|---|---|---|
safe_asset_path |
— |
Validated asset path |
page_context |
— |
Page context for computing relative path |
Returns
str
Relative asset URL
_find_fingerprinted_asset
1
str | None
▼
Find fingerprinted version of asset in output directory.
_find_fingerprinted_asset
1
str | None
▼
def _find_fingerprinted_asset(self, safe_asset_path: str) -> str | None
Parameters
| Name | Type | Description |
|---|---|---|
safe_asset_path |
— |
Validated asset path |
Returns
str | None
Fingerprinted asset path if found, None otherwise
Functions
normalize_and_validate_asset_path
1
str
▼
Normalize and validate the provided asset path to prevent traversal/absolute pa…
normalize_and_validate_asset_path
1
str
▼
def normalize_and_validate_asset_path(raw_path: str) -> str
Normalize and validate the provided asset path to prevent traversal/absolute paths.
Parameters
| Name | Type | Description |
|---|---|---|
raw_path |
str |
Raw asset path from template |
Returns
str
compute_relative_asset_path
3
str | None
▼
Compute relative path from page to asset for file:// protocol.
compute_relative_asset_path
3
str | None
▼
def compute_relative_asset_path(asset_path: str, page_context: Any, output_dir: Path) -> str | None
Parameters
| Name | Type | Description |
|---|---|---|
asset_path |
str |
Asset path (e.g., 'assets/css/style.css') |
page_context |
Any |
Page context with output_path |
output_dir |
Path |
Site output directory |
Returns
str | None