prettier-plugin-go-template icon indicating copy to clipboard operation
prettier-plugin-go-template copied to clipboard

`Invalid node root` when using template in root element tag

Open giggio opened this issue 7 months ago • 1 comments

This will fail because of invalid root, but it is valid:

<h{{ .Level }} id="{{ .Anchor }}" {{- with .Attributes.class }} class="{{ . }}" {{- end }}>
  {{- .Text -}}
</h{{ .Level }}>

This code is taken from the Hugo docs, so it is probably a common pattern.

I'm guessing it is the <h{{ .Level }} part that is faling.

Log is:

[error] layouts/blog/_markup/render-heading.html: Error: An error occured during printing. Found invalid node root.
[error]     at Object.print (node_modules/prettier-plugin-go-template/lib/index.js:65:19
[error]     at callPluginPrintFunction (node_modules/prettier/index.mjs:20175:20)

giggio avatar Apr 10 '25 00:04 giggio

Did you manage to solve this?

tomfran avatar May 17 '25 10:05 tomfran