Skip to content

Add RenderHTML and RenderHTMLPage - #24

Merged
archlemon merged 1 commit into
mainfrom
feat/render-html
Nov 28, 2026
Merged

archlemon merged 1 commit into
mainfrom
feat/render-html

Conversation

@archlemon

Copy link
Copy Markdown
Member

Summary

Implements phase 1 of #22.

  • wui.RenderHTML(el) serializes the browser renderer's vnode description (describeTree, Patch the DOM instead of replacing it on every render #19) to the HTML the WASM build puts inside #wui-root:
    • the same tags, classes and inline styles;
    • current values reflected as attributes: input value, textarea text, checked, the selected <option>;
    • Empty placeholders as <!---->, matching the live DOM;
    • attributes in sorted order, so the output is stable for golden files;
    • the container-query <style> emitted raw, not entity-escaped.
  • wui.RenderHTMLPage(title, el) wraps it in a standalone document with the base stylesheet, for static exports such as an HTML report from a terminal tool.
  • Both work in every build, with no browser and no syscall/js.
  • README: new "Testing views" section (RenderTUISized and RenderHTML side by side), plus the missing Layout and Gallery entries under Examples.

Hydrating a pre-rendered page (fast first paint) is left as the follow-up the issue describes.

Test plan

  • Unit tests for escaping, styled text, both button types, input values (and omission when empty), textarea, checked checkbox, selected option, placeholder, divider, link with query string, table, raw responsive CSS, deterministic output, page wrapper
  • A static page built from a mixed tree, opened in headless Chromium, matches the live rendering: values, checked box, selected option, progress bar and the right Responsive variant
  • go test ./..., GOOS=js GOARCH=wasm go vet .

Closes #22

RenderHTML serializes the browser renderer's vnode description of a
View to the HTML the WASM build puts in #wui-root: same tags, classes
and inline styles, values reflected as attributes (input value,
textarea text, checked, selected option), sorted attributes for stable
output, raw text for the container-query <style>. It needs no browser,
so it gives snapshot tests of the browser rendering in plain go test.

RenderHTMLPage wraps it in a standalone document with the base
stylesheet, for static exports.

The README gains a Testing views section, and the Layout and Gallery
examples are listed.

Closes #22
@archlemon
archlemon merged commit 4862fe1 into main Nov 28, 2026
2 checks passed
@archlemon
archlemon deleted the feat/render-html branch November 28, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RenderHTML: render a View to a static HTML string

1 participant