prettier-plugin-freemarker
v1.0.2
Published
Code formatter for FTL Freemarker templating
Maintainers
Readme
prettier-plugin-freemarker
A Prettier plugin for formatting FreeMarker template files (.ftl).
Installation
npm install --save-dev prettier prettier-plugin-freemarkerUsage
Command Line
Once installed, Prettier will automatically detect and use the plugin for .ftl files:
npx prettier --write "**/*.ftl"You can also explicitly specify the plugin:
npx prettier --plugin prettier-plugin-freemarker --write "**/*.ftl"Configuration
Add the plugin to your Prettier configuration file (.prettierrc, .prettierrc.json, etc.):
{
"plugins": ["prettier-plugin-freemarker"]
}Programmatic Usage
const prettier = require("prettier");
const plugin = require("prettier-plugin-freemarker");
const formatted = await prettier.format(code, {
parser: "freemarker",
plugins: [plugin],
});How It Works
This plugin extends Prettier with support for FreeMarker templates by providing:
- Languages: Registers the FreeMarker language with
.ftlfile extension - Parsers: Parses FreeMarker template syntax into an AST
- Printers: Converts the AST back to formatted code
Supported File Extensions
.ftl
License
MIT
