Skip to content

E0153: A second template in a template file ​

A .vuka.html file renders one struct, the one its header declares: its markup is that struct's, and nothing follows it. A func line after the markup starts a second template — a partial, a function component, a method of another type — which a file no longer holds.

A partial becomes its own component: a .vuka.html file whose struct's exported fields are the partial's parameters (a Children ui.Node field takes what is written between its tags), used as a tag. A piece that builds nodes from other components without markup of its own may be a Go function returning ui.Node in a .go file.

Wrong ​

html
<!-- list.vuka.html -->
<script lang="go">
package pages

type List struct {
	Items []string
}
</script>

<ul>
  for _, it := range Items {
    <Row text={it} />
  }
</ul>

func Row(text string)
<li>{text}</li>
html
<!-- list.vuka.html -->
<script lang="go">
package pages

type List struct {
	Items []string
}
</script>

<ul>
  for _, it := range Items {
    <Row text={it} />
  }
</ul>
html
<!-- row.vuka.html -->
<script lang="go">
package pages

type Row struct {
	Text string
}
</script>

<li>{Text}</li>

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.