Template tags¶
Load with {% load shard %}.
shard_scripts¶
Include framework JavaScript. Place once per page.
By default loads HTMX and shard.js only (~17 KB gzip). Pass alpine=True or set SHARD_LOAD_ALPINE = True to also load Alpine.js (~33 KB gzip total).
Preload hints for required scripts are enabled by default (SHARD_PRELOAD_SCRIPTS).
component / endcomponent¶
Render a component with optional slot content.
Self-closing (no slot content):
slot / endslot¶
Named slot inside a component block.
shard_root¶
Root element attributes for a component instance.
Outputs: id="shard-<id>" data-shard-scope="<scope>"
shard_action¶
URL for a specific action.
Prefer shard_htmx for most cases.
shard_htmx¶
Generate HTMX attributes for an action.
<button {% shard_htmx component "increment" %}>+</button>
<button {% shard_htmx component "search" trigger="keyup changed delay:300ms" swap="innerHTML" %}>
<button {% shard_htmx component "remove" index=forloop.counter0 %}>
shard_alpine¶
Generate Alpine.js x-data from get_client_state().
shard_child¶
Render a nested child component from within a component template.
Uses the parent component from context when available.