Return partial HTML (no document wrapper) for htmx or includes.
| Kind | Keyword |
| Since | 0.1.0 |
| Repeatable | yes |
fragment <path-or-name> [(<args>)] [requires <clause>]
| Name | Type | Required |
|---|---|---|
path-or-name |
string |
yes |
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.
fragment /users/:id/card
query user: SELECT name, email FROM user WHERE id = :id
html
<div class="card">{user.name}</div>
fragment badge(status, color="blue")
html
<span class="{color}">{status}</span>
⚠ Implementation touched after spec. Source code changed on
2026-05-20, but this entity's spec was last edited on2026-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 |