- guard nil receivers and nodes in core render flows - make Render() safe for nil input - add compile-time Node contract for Responsive Co-Authored-By: Virgil <virgil@lethean.io>
13 lines
307 B
Go
13 lines
307 B
Go
package html
|
|
|
|
// Render is a convenience function that renders a node tree to HTML.
|
|
// Usage example: html := Render(El("main", Text("welcome")), NewContext())
|
|
func Render(node Node, ctx *Context) string {
|
|
if node == nil {
|
|
return ""
|
|
}
|
|
if ctx == nil {
|
|
ctx = NewContext()
|
|
}
|
|
return node.Render(ctx)
|
|
}
|