Fix asset-url: use Jinja global instead of nonexistent urls.asset_url
The IO handler and bridge both imported asset_url from shared.infrastructure.urls, but it doesn't exist there — it's a Jinja global defined in jinja_setup.py. Use current_app.jinja_env.globals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -377,7 +377,10 @@ async def _io_asset_url(
|
|||||||
args: list[Any], kwargs: dict[str, Any], ctx: RequestContext
|
args: list[Any], kwargs: dict[str, Any], ctx: RequestContext
|
||||||
) -> str:
|
) -> str:
|
||||||
"""``(asset-url "/img/logo.png")`` → versioned static URL."""
|
"""``(asset-url "/img/logo.png")`` → versioned static URL."""
|
||||||
from shared.infrastructure.urls import asset_url
|
from quart import current_app
|
||||||
|
asset_url = current_app.jinja_env.globals.get("asset_url")
|
||||||
|
if asset_url is None:
|
||||||
|
raise RuntimeError("asset_url Jinja global not registered")
|
||||||
path = str(args[0]) if args else ""
|
path = str(args[0]) if args else ""
|
||||||
return asset_url(path)
|
return asset_url(path)
|
||||||
|
|
||||||
@@ -458,7 +461,10 @@ def _bridge_app_url(service, *path_parts):
|
|||||||
return app_url(str(service), path)
|
return app_url(str(service), path)
|
||||||
|
|
||||||
def _bridge_asset_url(*path_parts):
|
def _bridge_asset_url(*path_parts):
|
||||||
from shared.infrastructure.urls import asset_url
|
from quart import current_app
|
||||||
|
asset_url = current_app.jinja_env.globals.get("asset_url")
|
||||||
|
if asset_url is None:
|
||||||
|
raise RuntimeError("asset_url Jinja global not registered")
|
||||||
path = str(path_parts[0]) if path_parts else ""
|
path = str(path_parts[0]) if path_parts else ""
|
||||||
return asset_url(path)
|
return asset_url(path)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user