2026-02-16 23:43:05 +00:00
|
|
|
package html
|
|
|
|
|
|
|
|
|
|
// Render is a convenience function that renders a node tree to HTML.
|
2026-03-26 18:12:06 +00:00
|
|
|
// Usage example: html := Render(El("main", Text("welcome")), NewContext())
|
2026-02-16 23:43:05 +00:00
|
|
|
func Render(node Node, ctx *Context) string {
|
2026-03-29 23:10:48 +00:00
|
|
|
if node == nil {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2026-02-16 23:43:05 +00:00
|
|
|
if ctx == nil {
|
|
|
|
|
ctx = NewContext()
|
|
|
|
|
}
|
|
|
|
|
return node.Render(ctx)
|
|
|
|
|
}
|