GitHub - sgruendel/prettier-plugin-jte: Prettier plugin for jte template files. (original) (raw)
Prettier plugin for formatting Java JTE templates with Prettier.
This plugin targets Java-style .jte files and formats JTE directives while delegating HTML layout to Prettier's HTML printer.
It supports:
${...}and$unsafe{...}expressions@if,@elseif,@else,@endif@for,@else,@endfor@importand@param@template...(...)calls!{...}local Java code blocks@`...`content blocks<%-- ... --%>comments
It currently focuses on Java JTE syntax only. Kotlin .kte syntax is out of scope.
Install
npm install --save-dev prettier prettier-plugin-jte
Usage
Prettier will pick up the plugin automatically when it is installed locally and the file extension is .jte.
You can also invoke it explicitly:
npx prettier --write "src/**/*.jte" --parser jte
Example .prettierrc:
{ "plugins": ["prettier-plugin-jte"] }
Example
@import org.example.Page @param Page page
@if(page.getDescription() != null) @endif
@template.layout.page(
page = page,
content = @ <h1>${page.getTitle()}</h1>
)