Templates
Reactive embed — x-block
x-block
embeds another block by its route — rendered server-side on first paint, then re-fetched
and swapped in on the client with no full-page reload. Handy for composing a page from
independently-rendered fragments.
x-block
<div class="" x-block="'/embed-target'"></div>
Result
Hello from /embed-target
This block was rendered server-side and spliced in by
x-block
— no full-page reload.
no query on the href
The href is a URL, not a bare route name, so it may carry a query string. The embedded block
reads it as
$req.query
— the same request it would see if that route were fetched on its own.
x-block with a query string
<div class="" x-block="'/embed-target?who=' + who"></div>
Result
Hello from /embed-target
This block was rendered server-side and spliced in by
x-block
— no full-page reload.
$req.query.who = World