Raw Go
For some more advanced use cases it may be useful to write Go code statements in your template.
Use the {{ ... }}
syntax for this.
Variable declarations
Scoped variables can be created using this syntax, to reduce the need for multiple function calls.
component.templ
package main
templ nameList(items []Item) {
{{ first := items[0] }}
<p>
{ first.Name }
</p>
}
Output
<p>A</p>