Fixes formatting for go template files. The only peer dependency is prettier.
npm install --save-dev prettier-plugin-go-template
The following file types are detected automatically:
.gohtml
, .gotmpl
, .go.tmpl
, .tmpl
, .tpl
, .html.tmpl
To use it with GoHugo and basic .html
files, you'll have to override the used parser inside your .prettierrc
file:
{
"overrides": [
{
"files": ["*.html"],
"options": {
"parser": "go-template"
}
}
]
}
Make sure to always have installed both dependencies:
- prettier
- prettier-plugin-go-template
Also make sure that they are installed inside the same scope.
Install both globally (npm i -g
) or locally – otherwise prettier may not pick up the plugin.
- Resolve bug #19: Fix template comments.
- Resolve bug of single line if statements.
- Go block statements will now be indented accordingly. Except for
else
.- if, range, block, with, define, end
- Fix broken shortcodes. Thanks to @alqu for discovering & fixing the bug.
Thanks goes to these wonderful people (emoji key):
alqu 🐛 |
Gabriel Monteagudo 🐛 |
Bryan 🐛 |
Andreas Richter 🐛 |
Noah Brenner 💻 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!