{"id":14111032,"url":"https://github.com/NiklasPor/prettier-plugin-go-template","last_synced_at":"2025-08-01T11:33:46.923Z","repository":{"id":39117012,"uuid":"269728832","full_name":"NiklasPor/prettier-plugin-go-template","owner":"NiklasPor","description":"Fixes prettier formatting for go templates 🐹","archived":false,"fork":false,"pushed_at":"2023-07-26T13:18:10.000Z","size":561,"stargazers_count":343,"open_issues_count":23,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-01T11:12:11.680Z","etag":null,"topics":["gohugo","golang-template","hugo","prettier"],"latest_commit_sha":null,"homepage":"prettier-plugin-go-template-niklaspor.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NiklasPor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-05T17:59:43.000Z","updated_at":"2024-11-14T13:17:38.000Z","dependencies_parsed_at":"2024-06-18T13:46:16.863Z","dependency_job_id":"174cc7e6-e2f6-465d-b149-5a9ddb833e12","html_url":"https://github.com/NiklasPor/prettier-plugin-go-template","commit_stats":{"total_commits":161,"total_committers":8,"mean_commits":20.125,"dds":"0.27329192546583847","last_synced_commit":"d91c82e1377b89592ea3365e7e5569688fbc7954"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiklasPor%2Fprettier-plugin-go-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiklasPor%2Fprettier-plugin-go-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiklasPor%2Fprettier-plugin-go-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiklasPor%2Fprettier-plugin-go-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NiklasPor","download_url":"https://codeload.github.com/NiklasPor/prettier-plugin-go-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228375679,"owners_count":17910267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gohugo","golang-template","hugo","prettier"],"created_at":"2024-08-14T10:03:06.757Z","updated_at":"2024-12-05T21:30:50.653Z","avatar_url":"https://github.com/NiklasPor.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# prettier-plugin-go-template\n\n[![NPM Badge](https://img.shields.io/npm/v/prettier-plugin-go-template)](https://www.npmjs.com/package/prettier-plugin-go-template) [![CodeCov Badge](https://img.shields.io/codecov/c/github/niklaspor/prettier-plugin-go-template)](https://codecov.io/gh/NiklasPor/prettier-plugin-go-template) [![Contributions Badge](https://img.shields.io/github/all-contributors/niklaspor/prettier-plugin-go-template)](#contributors-)\n\nFormatter plugin for go template files. The only peer dependency is [prettier](https://www.npmjs.com/package/prettier).\n\n```bash\nnpm install --save-dev prettier prettier-plugin-go-template\n```\n\nStarting with Prettier 3 auto-discovery has been removed. Configuration is required ⬇️\n\n```json\n// .prettierrc\n{\n  \"plugins\": [\"prettier-plugin-go-template\"]\n}\n```\n\nThe following file types will be detected automatically:\n`.gohtml`, `.gotmpl`, `.go.tmpl`, `.tmpl`, `.tpl`, `.html.tmpl`\nIf you want to add support for `.html` read the section on it below the examples.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eInput\u003c/th\u003e\n\u003cth\u003eOutput\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n```html\n{{ if or .Prev .Next -}}\n{{ $p := where site.Pages }}\n\u003cdiv class=\"my-navigation\"\u003e\n{{ with $p.Next . -}}\n\u003ca href=\"{{ .RelPermalink }}\"\u003e\n\u003cdiv class=\"row\"\u003e\n\u003cdiv class=\"cell py-2\"\u003e\n  {{ .Title }} \n\u003c/div\u003e \u003c/div\u003e \u003c/a\u003e\n{{ end -}}\n\u003c/div\u003e\n{{ end -}}\n```\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n```html\n{{ if or .Prev .Next -}}\n  {{ $p := where site.Pages }}\n  \u003cdiv class=\"my-navigation\"\u003e\n    {{ with $p.Next . -}}\n      \u003ca href=\"{{ .RelPermalink }}\"\u003e\n        \u003cdiv class=\"row\"\u003e\n          \u003cdiv class=\"cell py-2\"\u003e{{ .Title }}\u003c/div\u003e\n        \u003c/div\u003e\n      \u003c/a\u003e\n    {{ end -}}\n  \u003c/div\u003e\n{{ end -}}\n```\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## GoHugo / `.html`\n\nTo use it with GoHugo and basic `.html` files, you'll have to override the used parser inside your `.prettierrc` file:\n\n```json\n{\n  \"plugins\": [\"prettier-plugin-go-template\"],\n  \"overrides\": [\n    {\n      \"files\": [\"*.html\"],\n      \"options\": {\n        \"parser\": \"go-template\",\n      },\n    },\n  ],\n}\n```\n\n## VSCode\n\nMake sure to always have installed **both** dependencies:\n\n- `prettier`\n- `prettier-plugin-go-template`\n\nAlso make sure that they are installed inside the same scope.\nInstall both globally (`npm i -g`) or locally – otherwise prettier may not pick up the plugin.\n\n\u003e Note: The global setup additional requires setting your VSCode prettier path to your global prettier path. You can read in [this issue](https://github.com/NiklasPor/prettier-plugin-go-template/issues/58#issuecomment-1085060511) how to set it up – should be doable in less than a minute if you have npm \u0026 VSCode already running.\n\n## Additional Options\n\n```js\n// .prettierrc\n{\n  /**\n   * Enables \u0026 disables spacing between go statements.\n   * E.g. {{ statement }} vs {{statement}}.\n   * Default: true\n   */\n  \"goTemplateBracketSpacing\": true\n}\n```\n\n## Ignoring Code\n\n#### Single Block\n\n```html\n\u003cdiv\u003e\n  \u003c!-- prettier-ignore --\u003e\n  {{if }}\n  {{end }}\n\u003c/div\u003e\n```\n\n#### Multiline\n\n```html\n\u003chtml\u003e\n  {{/* prettier-ignore-start */}}\n  \u003cscript\u003e\n    {{if }}\n    Whatever.\n    {{else }}\n    Psych.\n    {{end }}\n  \u003c/script\u003e\n  {{/* prettier-ignore-end */}}\n\u003c/html\u003e\n```\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/alqu\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/12250845?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ealqu\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Aalqu\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/commits?author=alqu\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/commits?author=alqu\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://www.gabrielmaldi.com\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/3728897?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eGabriel Monteagudo\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Agabrielmaldi\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/bgold0\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/4645400?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBryan\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Abgold0\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://richtera.org\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/708186?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAndreas Richter\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Arichtera\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://noahbrenner.github.io/\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/24858379?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eNoah Brenner\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/commits?author=noahbrenner\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/commits?author=noahbrenner\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://silverwind.io\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/115237?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003esilverwind\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-silverwind\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://codeberg.org/cpence\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/297075?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eCharles Pence\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Acpence\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://jasik.xyz\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/10626596?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eCaleb Jasik\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Ajasikpark\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/commits?author=jasikpark\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#example-jasikpark\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"#ideas-jasikpark\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"#maintenance-jasikpark\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"#question-jasikpark\" title=\"Answering Questions\"\u003e💬\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://DanGold.me\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/8890238?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDan Gold\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3ALandGod\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://mtlynch.io\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/7783288?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMichael Lynch\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/NiklasPor/prettier-plugin-go-template/issues?q=author%3Amtlynch\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNiklasPor%2Fprettier-plugin-go-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNiklasPor%2Fprettier-plugin-go-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNiklasPor%2Fprettier-plugin-go-template/lists"}