Add optional Datastar plumbing
This commit is contained in:
@@ -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) ?>&stream=1')">Patch a fragment</button>
|
||||
<div id="datastar-example-result">Waiting for a server patch.</div>
|
||||
</>;
|
||||
}
|
||||
Reference in New Issue
Block a user