Technical guide · 0.1.0-preview.4
HTML-first templates. Typed Go output.
Sandwich Hime is an HTML-first, ahead-of-time template engine for Go. Each .sando file defines one typed template; Hime-san validates its HTML contexts and emits a neighboring .sando.go component for the application build.
Templates are what authors write. Components are what those templates compile into and how rendered pieces compose.
Templates are ordinary HTML with occasional bursts of Go
| Form | Purpose |
|---|---|
<?sando go … ?> | Declares the Go package, imports, component name, and typed parameters. |
<? … ?> | Executes trusted Go statements such as conditions and loops. |
<?= expression ?> | Writes a value escaped for the inferred HTML context. |
<?~ component ?> | Renders another sando.Component and propagates its error. |
<?# … ?> | Adds a template comment that is omitted from output. |
<?sando go
package views
func Greeting(name string)
?>
<p>Hello, <?= name ?>.</p>
EOF closes the template. A file cannot declare a collection of unrelated templates, an implicit request object, or an inheritance hierarchy.
Composition, without an inheritance language
Layouts, partials, page bodies, rows, and reusable blocks are all ordinary typed components. <?~ … ?> renders another component at a safe HTML content boundary and propagates its error.
<?sando go
package views
func Page(view PageView)
?>
<?~ Layout(
Header(view.Header),
Article(view.Article),
Footer(view.Footer),
) ?>
Conditions and loops stay ordinary Go. Data crosses explicit function signatures. There is no reflection registry, template-name lookup, implicit request global, or separate inheritance DSL to keep synchronized.
Generated API
A generated template constructor returns the runtime's small component interface:
func Profile(page ProfileView) sando.Component
type Component interface {
Render(context.Context, io.Writer) error
}
Your handler decides when and where to render it. The compiler does not choose a router, middleware stack, response policy, or production process lifecycle.
Generated files include the compiler version, runtime ABI, source digest, and source mappings. They are designed to be committed so ordinary builds do not need the compiler.
Two development loops
Core, portable path
Until the first public versioned release, build the compiler from a neighboring source checkout. Generate or read-only check the templates, then use the project's normal Go commands:
cd ../sandwich-hime
go install ./cmd/himesan
cd ../your-project
himesan generate ./...
himesan check ./...
go test ./...
go build ./...
The application then builds with its generated Go and the Apache-2.0 sando runtime. The AGPL compiler is a development tool and is not linked into the service.
himesan bless is the friendly, read-only alias for check. A blessing means the generated output is current; it is not a substitute for Go type-checking or tests.
Optional, opinionated path
himesan dev --config himesan.json
himesan dev watches configured templates and project files, regenerates, builds your Go program, health-checks a loopback candidate, preserves the last healthy process when a change fails, and adds local reload diagnostics. It supervises your development server; it does not supply your application server or enter production.
go install gamertan.com/sandwich-hime/cmd/himesan@vX.Y.Z and go get gamertan.com/sandwich-hime/sando@vX.Y.Z. Do not use those placeholders as release coordinates today.Preview limitations
- San is a separate language and a possible future backend, not part of this preview. Sandwich Hime currently generates Go only; it does not parse
.san, promise compatibility, or publish a San timeline. - HTML text, quoted attributes, recognized URL attributes, and balanced content-boundary components form the supported context set.
- Script and style data require explicit trusted values. Dynamic tag or attribute construction is rejected.
- The language deliberately has no raw-output shortcut, reflection registry, request global, or template inheritance DSL.
himesan checkvalidates template structure, contexts, and generated-file freshness; the subsequent Go build is responsible for type-checking imports, names, and embedded Go expressions.- A handwritten
sando.Componentis trusted output capability. Context guarantees apply to compiler-generated components whose source passed Hime-san's analyzer. - Compatibility is not promised before 1.0. Commit generated output and review generator changes like other build tooling.
Continue with the security model or read about licensing and stewardship.