Documentation menu

Formatter

htmgo has a built-in formatter that can be used to format htmgo element blocks.

It is available through the 'htmgo' cli tool that is installed with htmgo.

To update the CLI, rerun go install github.com/franchb/htmgo/cli/htmgo/v2@latest.

Format Go files

htmgo format .
Copy
This will format all htmgo element blocks in your project recursively.
htmgo format ./my-file.go
Copy
This will format the file specified.

Before formatting

Copy
1h.Div(
2	h.Class("flex gap-2"), h.Text("hello"), h.Text("world"),
3)

After formatting

Copy
1h.Div(
2	h.Class("flex gap-2"),
3	h.Text("hello"),
4	h.Text("world"),
5)