Component can be used to render inside template, or render as standalone html (for htmx!).
t := app.Template() t.ParseComponent("table-body", ` {{range .}} <tr> <td>{{.ID}}</td> <td>{{.Name}}</td> </tr> {{end}} `) t.Parse("index", ` <table> <thead> <tr> <th>ID</th> <th>Name</th> </tr> </thead> <tbody> {{component "table-body" .List}} </tbody> </table> `)
func tableBody(ctx *hime.Context) error { data := getData() return ctx.Component("table-body", data) }
func tableBody(ctx *hime.Context) error { data := getData() return ctx.Render(` {{range .}} <tr> <td>{{.ID}}</td> <td>{{.Name}}</td> </tr> {{end}} `, data) }
There was an error while loading. Please reload this page.