Intermediate May 3, 2026 · 2 min read

What each weaver produces, and what shape its output takes. Eleven templates total, one entry below per template.

SQL — internal/templates/sql/

create_table.sql.tmpl

For each Thread, a complete CREATE TABLE with the four audit columns (id, created_at, updated_at, created_by), the user-declared fields, PRIMARY KEY on id, UNIQUE INDEX on unique: true fields, secondary INDEX on searchable: true fields, and ENGINE=InnoDB DEFAULT CHARSET=utf8mb4. Foreign keys (from link fields) are emitted as comments — PlanetScale does not enforce FKs.

alter_table.sql.tmpl

Currently a stub consumed by loom stitch for ADD COLUMN. Produces one ALTER TABLE statement per added column.

Go — internal/templates/go/

model.go.tmpl

A struct under models.<Model>. Embedded db:/json:/validate: tags align with sqlx + go-playground/validator. Includes a TableName() method for identifier consistency. Run through go/format.Source before write — gofmt-stable.

handler.go.tmpl

Five HTTP handlers under handlers: List<Model>s, Get<Model>, Create<Model>, Update<Model>, Delete<Model>. Each checks permissions.Can(user, "<Model>", action) before any DB access. SQL uses sqlx named-parameter execution with the model struct as input.

routes.go.tmpl

A single Mount<Model>Routes(r chi.Router, db *sqlx.DB) function that registers the five HTTP routes under /api/<table>.

handler_test.go.tmpl

Stub test asserting the list endpoint returns 403 without authentication. Real coverage is the user's job.

SvelteKit — internal/templates/svelte/

list_page.svelte.tmpl

A +page.svelte rendering a table of records. Uses fetch('/api/<table>') on mount; columns come from list_view.columns (or all fields if not set).

form_page.svelte.tmpl

A +page.svelte rendering a create-or-edit form. Bind directives on each field; the right <input type> per field type. Submits via fetch to POST or PUT depending on whether record.id is set.

detail_page.svelte.tmpl

A +page.svelte rendering a single record's fields as a <dl>. Has an Edit link to the form page.

HTMX — internal/templates/htmx/

form.html.tmpl

A <form> with hx-post (Create) or hx-put (Update) attributes pointing at /api/<table>. Server-rendered partial, no client-side framework.

list.html.tmpl

A <table> with one row per record. Each row has hx-get to navigate to the detail view. Uses Go template syntax for the runtime substitution layer.

Where these templates live

All eleven .tmpl files are bundled into the loom binary via embed.FS (internal/templates/embed.go). They're not copied into your project — loom weave reads them from inside the binary.

Customising the templates

For v0.1.0, template customisation requires forking the framework. A future version may support an override directory in your project (docs/templates/sql/create_table.sql.tmpl) that takes precedence over the bundled defaults.

See also

  • Reference → CLI Command Reference — flags for loom weave
  • Concepts → Interpreter Mode vs Ejected Code — when generated Go runs vs sits idle
Was this article helpful?