I found almost nothing on how to format Go templates so here's a quick guide.
- Create your templates, I'm using the
<name>.<type>.htmlnotation, the<type>is one of page, layout or partial - Ensure
prettieris installed globally as well as a plugin to make prettier work with Go templates
npm i -g prettier prettier-plugin-go-template
- Add this
.prettierrcto the root of your project
{
"overrides": [
{
"files": ["*.html"],
"options": {
"parser": "go-template"
}
}
]
}
- Run the prettier write command whenever you want to format your templates
prettier -w .
the . represents the current directory