go-html/README.md
Snider 09b48e00dc
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
chore(html): swap errors.Is for core.Is in codegen CLI, document WASM size guard-rails
- cmd/codegen/main.go: drop "errors" stdlib import, use core.Is per Core convention
  (non-WASM path).
- layout.go, path.go, responsive.go: add header notes documenting why these files
  use stdlib (errors/strings/strconv) instead of core — RFC §7 caps WASM at
  3.5 MB raw / 1 MB gzip, and dappco.re/go/core transitively pulls fmt/os/log.
- README.md, docs/index.md: migrate stale forge.lthn.ai/core/go-html module path
  to canonical dappco.re/go/core/html; refresh dependency diagram and Go version.

All spec features are already implemented; this is spec-parity maintenance.

Verified: go build ./..., go vet ./..., go test ./... all green (WASM size test
back to 2.12 MB raw / 630 KB gzip after short-lived core-import regression).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 20:01:28 +01:00

48 lines
2 KiB
Markdown

[![Go Reference](https://pkg.go.dev/badge/dappco.re/go/core/html.svg)](https://pkg.go.dev/dappco.re/go/core/html)
[![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](LICENSE.md)
[![Go Version](https://img.shields.io/badge/Go-1.26-00ADD8?style=flat&logo=go)](go.mod)
# go-html
HLCRF DOM compositor with grammar pipeline integration for server-side HTML generation and optional WASM client rendering. Provides a type-safe node tree (El, Text, Raw, If, Each, Switch, Entitled, AriaLabel, AltText), a five-slot Header/Left/Content/Right/Footer layout compositor with deterministic `data-block` path IDs and ARIA roles, a responsive multi-variant wrapper, a server-side grammar pipeline (StripTags, GrammarImprint via go-i18n reversal, CompareVariants), a build-time Web Component codegen CLI, and a WASM module (2.90 MB raw, 842 KB gzip) exposing `renderToString()`.
**Module**: `dappco.re/go/core/html`
**Licence**: EUPL-1.2
**Language**: Go 1.26
## Quick Start
```go
import html "dappco.re/go/core/html"
page := html.NewLayout("HCF").
H(html.El("nav", html.Text("i18n.label.navigation"))).
C(html.El("main",
html.El("h1", html.Text("i18n.label.welcome")),
html.Each(items, func(item Item) html.Node {
return html.El("li", html.Text(item.Name))
}),
)).
F(html.El("footer", html.Text("i18n.label.copyright")))
rendered := page.Render(html.NewContext("en-GB"))
```
## Documentation
- [Architecture](docs/architecture.md) — node interface, HLCRF layout, responsive compositor, grammar pipeline, WASM module, codegen CLI
- [Development Guide](docs/development.md) — building, testing, WASM build, server/client split rules
- [Project History](docs/history.md) — completed phases and known limitations
## Build & Test
```bash
go test ./...
go test -bench . ./...
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o gohtml.wasm ./cmd/wasm/
go build ./...
```
## Licence
European Union Public Licence 1.2 — see [LICENCE](LICENCE) for details.