Skip to content

sgruendel/prettier-plugin-jte

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prettier-plugin-jte

CI Depfu npm version

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
  • @import and @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)
    <meta name="description" content="${page.getDescription()}">
@endif

@template.layout.page(
    page = page,
    content = @`
        <h1>${page.getTitle()}</h1>
    `
)

About

Prettier plugin for jte template files.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors