add instructions for running the formatter
This commit is contained in:
parent
8736c00fd5
commit
504a64aa63
3 changed files with 63 additions and 1 deletions
|
|
@ -129,7 +129,8 @@ func CollapseButton() *h.Element {
|
|||
`),
|
||||
),
|
||||
h.UnsafeRaw("☰"),
|
||||
// The icon for collapsing the sidebar
|
||||
|
||||
// The icon for collapsing the sidebar
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
60
htmgo-site/md/docs/8_miscellaneous/3_htmgo format.md
Normal file
60
htmgo-site/md/docs/8_miscellaneous/3_htmgo format.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
## Htmgo Format
|
||||
|
||||
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.
|
||||
|
||||
**Note:** if you have previously installed htmgo, you will need to run `GOPROXY=direct go install github.com/maddalax/htmgo/cli/htmgo@latest` to update the cli tool.
|
||||
|
||||
<br>
|
||||
To use it, run the following command:
|
||||
|
||||
```bash
|
||||
// format all .go files in the current directory recursively
|
||||
htmgo format .
|
||||
|
||||
// format the file specified
|
||||
htmgo format ./my-file.go
|
||||
```
|
||||
|
||||
This will format all htmgo element blocks in your project.
|
||||
|
||||
**Example:**
|
||||
|
||||
```go
|
||||
h.Div(
|
||||
h.Class("flex gap-2"), h.Text("hello"), h.Text("world"),
|
||||
)
|
||||
```
|
||||
|
||||
**Output:**
|
||||
|
||||
```go
|
||||
h.Div(
|
||||
h.Class("flex gap-2"),
|
||||
h.Text("hello"),
|
||||
h.Text("world"),
|
||||
)
|
||||
```
|
||||
|
||||
## Running htmgo format on save
|
||||
|
||||
### Jetbrains IDE's
|
||||
|
||||
1. Go to Settings -> Tools -> File Watchers -> + custom
|
||||
|
||||
2. Set the following values:
|
||||
|
||||
```yaml
|
||||
Name: htmgo format
|
||||
File Type: Go
|
||||
Scope: Current File
|
||||
Program: htmgo
|
||||
Arguments: format $FilePath$
|
||||
Output paths to refresh: $FilePath$
|
||||
Working directory: $ProjectFileDir$
|
||||
```
|
||||
|
||||
3. Save the file watcher and ensure it is enabled
|
||||
|
||||
4. Go to `Settings -> Tools -> Actions On Save` and ensure the `htmgo format` action is enabled
|
||||
|
|
@ -47,6 +47,7 @@ func GoOutput(content string) *h.Element {
|
|||
h.Class("absolute top-0 right-0 p-2 bg-slate-800 text-white rounded-bl-md cursor-pointer"),
|
||||
h.Text("Copy"),
|
||||
h.OnClick(
|
||||
// language=JavaScript
|
||||
js.EvalJs(`
|
||||
if(!navigator.clipboard) {
|
||||
alert("Clipboard API not supported");
|
||||
|
|
|
|||
Loading…
Reference in a new issue