Registry / web-framework / prettier-plugin-go-template

prettier-plugin-go-template

JSON →
library0.0.15jsnpmunverified

Prettier plugin for formatting Go and GoHugo templates. Current stable version 0.0.15, compatible with Prettier ^3.0.0. Requires Node >=14. Automatically formats .gohtml, .gotmpl, .go.tmpl, .tmpl, .tpl, .html.tmpl files. Supports bracket spacing option. For .html files, parser override is needed. No other dependencies beyond Prettier. Actively maintained.

npm install prettier-plugin-go-template
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-GO
P
prettier-plugin-go-template
web-frameworkjavascriptv0.0.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Install and configure the plugin in .prettierrc for Prettier 3+.

npm install --save-dev prettier prettier-plugin-go-template # .prettierrc { "plugins": ["prettier-plugin-go-template"], "goTemplateBracketSpacing": true }
Debug
Known issues
breakingStarting with Prettier 3, auto-discovery has been removed. Configuration is required.
fix
Add 'plugins': ['prettier-plugin-go-template'] to .prettierrc.
affects: >=3.0.0
gotchaFor GoHugo .html files, the default HTML parser is used unless overridden. Mixed templates may break.
fix
Add parser override in .prettierrc: overrides [{ files: ['*.html'], options: { parser: 'go-template' } }].
affects: all
gotchaGlobal and local installations must match. VSCode may not detect plugin if installed in different scope.
fix
Install both prettier and plugin either both globally or both locally.
affects: all
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-go-template'
Plugin not installed or not in same scope as prettier.
fix
Run: npm install --save-dev prettier prettier-plugin-go-template
Couldn't resolve parser "go-template"
The plugin is not loaded or parser name is incorrect.
fix
Add 'plugins': ['prettier-plugin-go-template'] to .prettierrc.
Upgrade
Version history
0.0.15latest on npm
Audit
Dependencies
prettierrequiredpeer dependency required for plugin functionality
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-go-template — npm install prettier-plugin-go-template · libregistry