-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Gomponents | ||
|
||
Fuego supports rendering HTML templates with [Gomponents](https://github.com/maragudk/gomponents). | ||
|
||
Just use the `fuego.Gomponent` type as a return type for your handler, and return the gomponent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# HTML Rendering | ||
|
||
Fuego is not only capable to handle XML and JSON, it can also render HTML. | ||
|
||
It supports templating with [html/template](https://pkg.go.dev/html/template), [Templ](https://github.com/a-h/templ), and [Gomponents](https://github.com/maragudk/gomponents). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# html/template | ||
|
||
Fuego supports rendering HTML templates with the [html/template](https://pkg.go.dev/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. | ||
|
||
```go | ||
// highlight-next-line | ||
func (rs Ressource) unitPreselected(c fuego.Ctx[any]) (fuego.HTML, error) { | ||
id := c.QueryParam("IngredientID") | ||
|
||
ingredient, err := rs.IngredientsQueries.GetIngredient(c.Context(), id) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
// highlight-start | ||
return c.Render("preselected-unit.partial.html", fuego.H{ | ||
"Units": types.UnitValues, | ||
"SelectedUnit": ingredient.DefaultUnit, | ||
}) | ||
// highlight-end | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters