Skip to content
PluginStats

prettier-plugin-go-template-guard weekly downloads statistics

By abiiranathan · npm · Prettier plugins

Wraps prettier-plugin-go-template and fixes multiline Go template actions inside HTML attribute values, which otherwise render as literal whitespace in the attribute.

View on npm Stale · Oct 17, 2026

prettier-plugin-go-template-guard has 3 recorded weekly downloads on npm, a decrease of 72.7% over the past 30 days, ranking #2093 of 2,256 tracked listings.

Weekly downloads
3
Official API · Oct 17, 2026
7-day growth
-88.0%
-22 weekly downloads
30-day growth
-72.7%
-8 weekly downloads
90-day growth
—
Insufficient history
Rank
#2093
Among tracked npm listings

About prettier-plugin-go-template-guard

prettier-plugin-go-template-guard

Wraps prettier-plugin-go-template and fixes one specific bug in its output: when a Go template action ({{ if .X }}...{{ end }}) inside an HTML attribute value gets reformatted onto multiple lines, the newlines and indentation become part of the literal attribute value at render time. This breaks a lot of code assumptions causing bugs.

Before (what prettier-plugin-go-template alone produces):

This renders as value="\n \n 123\n \n " instead of value="123".

After (this plugin):

Attribute values with real text next to a template action keep their meaningful spacing (e.g. Tailwind class boundaries, "Total: 123 items" wording) — only pure indentation/formatting whitespace is collapsed. See src/fixer.js for the exact rules.

URL-valued attributes (href, src, action, formaction, and the hx-get/hx-post/hx-put/hx-delete/hx-patch/hx-push-url htmx set) are handled differently: literal whitespace is removed entirely, because a space in a URL is percent-encoded and silently changes the request. Without this, a reformatted attribute like hx-post="/accounts/36/ deactivate " requests /accounts/36/%20deactivate and 404s. Selector- and text-valued attributes (hx-target, hx-include, class, data-*, …) are not affected, since their spaces are significant.

Why this exists

prettier-plugin-go-template formats .html files containing Go text/template/html/template syntax. Like any HTML formatter, it's free to wrap long attribute values onto multiple lines for readability. That's harmless for element content, but Go's template engine renders attribute values verbatim — so a value that looks nicely indented in your editor renders with literal newlines and spaces baked into the DOM at runtime. This plugin patches that one gap without needing a fork or a patched copy of the upstream plugin.

How it works

This is a thin wrapper, not a fork. It registers a new parser, go-template-guard, whose parse step runs the entire file through a normal, nested prettier.format() call using the real prettier-plugin-go-template parser/printer (plus any other plugins you've configured — Tailwind class sorting, prettier-plugin-classnames, etc. — all forwarded through automatically), and then runs the attribute-value fixer once over that fully-formatted result.

When nothing in a file is affected by the bug, output is byte-identical to formatting with plain prettier-plugin-go-template — this plugin never changes anything beyond the specific pattern it targets.

Install

prettier and prettier-plugin-go-template are peer dependencies, not bundled — your project's existing versions are used.

Configure

In your .prettierrc.json, swap the parser value from go-template to go-template-guard in your *.html override, and add this plugin to the plugins array (its position relative to your other plugins doesn't matter — it's not itself a formatter, just a coordination layer):

goTemplateBracketSpacing and other prettier-plugin-go-template options are still respected — they're read by the real plugin during the nested inner format call, since this wrapper forwards options straight through.

Development

Tests are under test/:

• fixer.test.js covers the text-collapse logic in isolation (regex matching, whitespace collapsing, idempotency). • integration.test.js runs the actual Prettier plugin end-to-end, including a regression test for a bug caught during development where the nested format call originally dropped the caller's other configured plugins.

Limitations

• The fixer is a plain-text/regex pass over already-formatted output, not an HTML/AST parser — deliberately, since an AST parser would normalize whitespace on parse and hide the exact bug being fixed. This is fine for the attribute-value pattern it targets, but it means it doesn't understand HTML structure beyond attribute boundaries. • Adds one extra full nested prettier.format() call per file compared to using prettier-plugin-go-template directly. This is a deliberate correctness/performance tradeoff — see the comment in index.js for why.

Description from the npm listing.

  • prettier
  • prettier-plugin
  • go-template
  • html

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

prettier-plugin-go-template-guard weekly downloads on npm, last 90 days: 3 weekly downloads as of Oct 17, 2026.prettier-plugin-go-template-guardWeekly downloads on npm · Last 90 days3downloads / week050100150200250300350Jul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 17, 2026 · 88 observations · Updated Oc…pluginstats.com
prettier-plugin-go-template-guard weekly downloads on npm, last 90 days: 3 weekly downloads as of Oct 17, 2026.

7/30/90-day growth

prettier-plugin-go-template-guard weekly downloads growth on npm: -88.0% over 7 days, -72.7% over 30 days, 90-day growth unavailable.prettier-plugin-go-template-guardWeekly downloads growth on npm3downloads / week now7-day growth-22 weekly downloads-88.0%30-day growth-8 weekly downloads-72.7%90-day growth+3 weekly downloadsInsufficient historyGrowth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
prettier-plugin-go-template-guard weekly downloads growth on npm: -88.0% over 7 days, -72.7% over 30 days, 90-day growth unavailable.

Ranking history

prettier-plugin-go-template-guard npm ranking history: currently #2093 (by weekly downloads).prettier-plugin-go-template-guardnpm ranking · by weekly downloads · Last 90 days#2093current rank#2086#2088#2090#2092#2094#2096Jul 21Aug 5Aug 20Sep 4Sep 19Oct 4Oct 19rankOct 18, 2026 – Oct 19, 2026 · 2 observations · Updated Oct 17, 2026pluginstats.com
prettier-plugin-go-template-guard npm ranking history: currently #2093 (by weekly downloads).

Listing placement

All npm2,256 listings · 113 pages · 1,130 shown · page 105, #14 (overall #2,094)
All npm: every listing in weekly downloads order

Listing placement

Prettier plugins244 listings · 13 pages · page 8, #10 (overall #150)
Prettier plugins: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (121)
Recent weekly downloads observations for prettier-plugin-go-template-guard
Date (UTC)Weekly downloadsChange vs. previous
3-2
5-1
6-3
9-2
110
11-3
14-11
25-8
33-157
190+3
187+2
1850
185+5
180—

Similar npm Prettier plugins plugins

All 20 prettier-plugin-go-template-guard alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/prettier-plugin-go-template-guard. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.