prettier-plugin-jte
raw JSON → 1.2.0 verified Sat Apr 25 auth: no javascript
A Prettier plugin (v1.2.0) for formatting Java JTE template files. Compatible with Prettier ^3.0.0 and maintained by the JTE community. Supports JTE expressions, directives (@if, @for, @import, @param, @template calls), content blocks, and HTML formatting via Prettier's HTML printer. Actively developed with monthly releases. Differentiates from generic template formatters by understanding JTE-specific syntax and preserving whitespace semantics.
Common errors
error Cannot find module 'prettier-plugin-jte' ↓
cause Plugin not installed or not in node_modules.
fix
Run "npm install --save-dev prettier-plugin-jte" in the project root.
error Error: Loading plugin 'prettier-plugin-jte' failed: Cannot find module 'prettier' ↓
cause Prettier is not installed as a peer dependency.
fix
Run "npm install --save-dev prettier" to install Prettier v3+.
error Error: Unsupported parser: "jte" ↓
cause Prettier version < 3.0.0 does not support custom plugins.
fix
Upgrade Prettier to ^3.0.0.
Warnings
gotcha Plugin requires Prettier v3 or higher. Using with Prettier v2 will silently fail. ↓
fix Upgrade Prettier to ^3.0.0: npm install prettier@latest --save-dev
gotcha The plugin only supports .jte files – it does not support .kte (Kotlin JTE) syntax. ↓
fix Use a different formatter for .kte files, or convert to .jte if possible.
gotcha Explicit --parser jte flag may be required if Prettier does not auto-detect .jte files. ↓
fix Run prettier with --parser jte or ensure .prettierrc includes 'overrides': [{'files': '*.jte', 'options': {'parser': 'jte'}}]
Install
npm install prettier-plugin-jte yarn add prettier-plugin-jte pnpm add prettier-plugin-jte Imports
- plugin (in .prettierrc) wrong
plugins: ['prettier-plugin-jte'] (no require, no import, just string)correctplugins: ['prettier-plugin-jte'] - Default import (for programmatic use) wrong
const plugin = require('prettier-plugin-jte')correctimport plugin from 'prettier-plugin-jte' - TypeScript import (type)
import type { Plugin } from 'prettier'
Quickstart
# Install as a dev dependency
npm install --save-dev prettier prettier-plugin-jte
# Create or update .prettierrc
cat > .prettierrc << 'EOF'
{
"plugins": ["prettier-plugin-jte"]
}
EOF
# Format a JTE file
npx prettier --write "src/main/resources/**/*.jte"
# Example input file: src/main/resources/template.jte
# @import org.example.Page
# @param Page page
#
# @if(page.getDescription() != null)
# <meta name="description" content="${page.getDescription()}">
# @endif
#
# After formatting, the file gets consistent indentation and spacing.