Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 1.55 KB

File metadata and controls

68 lines (47 loc) · 1.55 KB

fragment

Return partial HTML (no document wrapper) for htmx or includes.

Kind Keyword
Since 0.1.0
Repeatable yes

Syntax

fragment <path-or-name> [(<args>)] [requires <clause>]

Arguments

Name Type Required
path-or-name string yes

Description

A fragment returns a slice of HTML without <html>/<body> wrapping. Fragments come in two flavors: route-based (fragment <path>), used as htmx targets that respond to AJAX requests, and component-based (fragment <name>(<args>)), used as reusable template includes invoked from other fragments or pages.

Children

Examples

Route-based htmx fragment

fragment /users/:id/card
  query user: SELECT name, email FROM user WHERE id = :id
  html
    <div class="card">{user.name}</div>

Reusable component

fragment badge(status, color="blue")
  html
    <span class="{color}">{status}</span>

See also

Provenance

Implementation touched after spec. Source code changed on 2026-05-20, but this entity's spec was last edited on 2026-05-08. The description may be out of date.

Spec last touched 5da8498 (2026-05-08)
Source last touched af278bb (2026-05-20)
Source files internal/parser/parser.go