Skip to content

E0152: A template file declares no struct above its markup ​

A .vuka.html file is one struct and its markup: the struct is declared in the file's <script lang="go">, with its hooks and methods, and the markup below is its view. The file starts with its markup instead, its struct declared in a .go or .vuka file beside it, so the two have to be kept in step by hand.

Move the struct's declaration, its decorated hooks and its methods into the header; the types it uses that aren't rendered — a form's input, an enum — stay in logic files.

Wrong ​

go
// counter.go
package components

type Counter struct {
	ui.Live
	n int
}

func (c *Counter) Inc() { c.n++ }
html
<!-- counter.vuka.html -->
<script lang="go">
package components
</script>

<button onClick={c.Inc}>{n}</button>
html
<!-- counter.vuka.html -->
<script lang="go">
package components

type Counter struct {
	ui.Live
	n int
}

func (c *Counter) Inc() { c.n++ }
</script>

<button onClick={c.Inc}>{n}</button>

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.