Skip to content

E0128: A value doesn't fit its hole ​

A hole of ui.HTML takes what its place allows: a child takes nodes, text and components; text in title and textarea takes a string or number; an attribute's value what a JSX attribute takes (an on… attribute a handler, class a ui.Class, style a ui.Style); part of a value a string or number; class:name={…} a bool or a ui.State[bool]; and {attrs...}, where an attribute goes, a ui.Attr, []ui.Attr or templ.Attributes. The value's type can't fill its hole, so the render fails. Reported by vukavet where the type is known, and when the markup renders.

The compiler reports two more. A stateful shape's value — its markup a method of its pointer — in a child hole would print as text: the compiler takes its address when it can ({Card{Title: "a"}}, {c}), and a value it can't ({p.card()}, a call's result) is this error; hold it in a variable. And a stylesheet has no holes: {Pct} in a <style> would be CSS as it is; set the value as a CSS variable, style:--pct={Pct}, and read var(--pct).

Wrong ​

go
attrs := ui.Attr{Name: "id", Value: "row"}
return ui.HTML(`<tr>{attrs}</tr>`, attrs)
go
attrs := ui.Attr{Name: "id", Value: "row"}
return ui.HTML(`<tr {attrs...}></tr>`, attrs)

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.