Add optional Datastar plumbing

This commit is contained in:
root
2026-07-30 19:41:52 +00:00
parent d0efab7db0
commit 36d6207bf2
5 changed files with 82 additions and 0 deletions
@@ -0,0 +1,20 @@
#load "../lib/app.uce"
#load "../lib/datastar.uce"
COMPONENT(Request& context)
{
if(context.get["stream"] == "1")
{
datastar_sse_headers(context);
print(datastar_patch_elements("<div id=\"datastar-example-result\">Server-rendered UCE Datastar fragment</div>"));
return;
}
<>
<h1>Datastar optional example</h1>
<p>Datastar is vendored beside the starter client libraries for future server-rendered islands. It is not loaded globally.</p>
<script type="module" src="<?= app_asset_url("js/datastar.js", context) ?>"></script>
<button class="btn" data-on:click="@get('<?= app_link("datastar-example", context) ?>&amp;stream=1')">Patch a fragment</button>
<div id="datastar-example-result">Waiting for a server patch.</div>
</>;
}