Registry / devops / prettier-plugin-templ-script

prettier-plugin-templ-script

JSON →
library1.0.0jsnpmunverified

Prettier plugin for formatting .templ files, specifically script elements and class attributes. Version 1.0.0, stable. It formats JavaScript inside <script> tags and class attributes in templ elements, with Tailwind CSS compatibility. Differentiators include Go-friendly default settings (tabs) and a templMode option to control formatting scope. Requires prettier as a peer dependency. Cannot handle nested script elements.

npm install prettier-plugin-templ-script
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-TE
P
prettier-plugin-templ-script
devopsjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import prettierPluginTemplScript from 'prettier-plugin-templ-script'
const prettierPluginTemplScript = require('prettier-plugin-templ-script')
ESM only as of v1.0.0
PrettierPluginTemplScript
import { PrettierPluginTemplScript } from 'prettier-plugin-templ-script'
Named export available for TypeScript usage
plugin
// In prettier config: plugins: ['prettier-plugin-templ-script']
// Do not use: plugins: ['@prettier/plugin-templ-script']
Plugin is typically used via config, not imported directly

Demonstrates installation, configuration, and usage of the plugin with Prettier.

// Install npm install --save-dev prettier prettier-plugin-templ-script // .prettierrc.json { "plugins": ["prettier-plugin-templ-script"], "templMode": "both" } // Run npx prettier --write "src/**/*.templ"
Debug
Known issues
gotchaCannot format nested script elements; only top-level script tags are supported.
fix
Avoid nesting <script> tags inside other elements.
affects: >=1.0.0
gotchaDefault formatting uses tabs (to align with Go convention); may conflict with existing Prettier settings.
fix
Set tabWidth and useTabs in Prettier config if needed.
affects: >=1.0.0
gotchaWorks only with .templ files; other file types are ignored.
fix
Ensure file extension is .templ.
affects: >=1.0.0
deprecatedNo known deprecations in v1.0.0.
fix
None.
affects: >=1.0.0
breakingBreaking changes: none in initial release.
fix
None.
affects: >=1.0.0
Errors
Common errors & fixes
Error: prettier-plugin-templ-script: Plugin could not be loaded. Are you sure it is installed?
Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev prettier-plugin-templ-script' and ensure it's in your project dependencies.
TypeError: prettier-plugin-templ-script is not a function
Trying to use plugin as a direct import in code instead of config entry.
fix
Add plugin to Prettier config as a string in plugins array, not as an imported module.
No parser could be inferred for file: example.templ
Plugin not properly registered or file extension not recognized.
fix
Ensure plugin is listed in .prettierrc plugins array and restart Prettier.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
prettierrequiredpeer dependency required for plugin functionality
Agent activity
14 hits · last 30 days
node
14
Resources
prettier-plugin-templ-script — npm install prettier-plugin-templ-script · libregistry