go-html/cmd/wasm/render_shared.go
Virgil 3bc82e27ce
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
test(wasm): add host-side render coverage
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 01:35:13 +00:00

35 lines
759 B
Go

// SPDX-Licence-Identifier: EUPL-1.2
package main
import html "dappco.re/go/core/html"
// renderLayout builds an HLCRF layout from slot nodes and renders it.
// The helper is shared by the JS entrypoint and host-side tests so the
// slot-to-layout mapping stays covered outside the wasm build.
func renderLayout(variant, locale string, slots map[string]html.Node) string {
ctx := html.NewContext(locale)
layout := html.NewLayout(variant)
for _, slot := range canonicalSlotOrder {
node, ok := slots[slot]
if !ok || node == nil {
continue
}
switch slot {
case "H":
layout.H(node)
case "L":
layout.L(node)
case "C":
layout.C(node)
case "R":
layout.R(node)
case "F":
layout.F(node)
}
}
return layout.Render(ctx)
}