Module

server.alpine

Alpine.js script injection — opt-in local UI state support.

Injects the Alpine.js script before</body> when AppConfig(alpine=True). Usesdeferso Alpine runs after DOM parsing; Alpine 3 auto-discovers elements including those swapped by htmx.

Controlled byAppConfig(alpine=True) (default: False).

Functions

alpine_snippet 2 str
Build the Alpine.js script tag for injection.
def alpine_snippet(version: str, csp: bool = False) -> str
Parameters
Name Type Description
version str

Alpine version (e.g. "3.15.8").

csp bool

If True, use the CSP-safe build for strict Content-Security-Policy.

Default:False
Returns
str