Prettier plugin for .templ files with script element and class attribute formatting.
Note: This cannot work with nested script elements.
- Formats JavaScript in script elements (defaults to tabs for Go convention consistency)
- Formats class attributes in all elements (compatible with Tailwind's Prettier plugin)
npm install --save-dev prettier-plugin-templ-script{
"plugins": ["prettier-plugin-templ-script"]
}Control which parts of templ files to format.
"both"(default) - Format both script and class attributes"script-only"- Format only script elements"class-only"- Format only class attributes
{
"plugins": ["prettier-plugin-templ-script"],
"templMode": "both"
}