html/template
Fuego supports rendering HTML templates with the html/template package.
Just use the fuego.HTML
type as a return type for your handler, and return
c.Render()
with the template name and data.
import (
"github.com/go-fuego/fuego"
"github.com/go-fuego/fuego/examples/full-app-gourmet/store/types"
)
func (rs Resource) unitPreselected(c fuego.ContextNoBody) (fuego.HTML, error) {
id := c.QueryParam("IngredientID")
ingredient, err := rs.IngredientsQueries.GetIngredient(c.Context(), id)
if err != nil {
return "", err
}
return c.Render("preselected-unit.partial.html", fuego.H{
"Units": types.UnitValues,
"SelectedUnit": ingredient.DefaultUnit,
})
}