A plugin for prettier-plugin-twig-melody that adds subtle formatting enhancements for Twig/Nunjucks templates. Current stable version is 1.0.1. It improves HTML element formatting to be more like Prettier (e.g., keeping short elements on one line, breaking long attributes) and prints empty {% block %} statements on a single line. No new releases since January 2023; the project is in maintenance mode as the author notes the Twig plugin is not well compatible with Nunjucks. Peer dependencies: prettier ^2.1.2 and prettier-plugin-twig-melody ^0.4.6. Key differentiator: addresses limitations of the base plugin for Nunjucks frontmatter and HTML formatting.
npm install prettier-plugin-twig-enhancementsVerified import paths — ran on the pinned version, not inferred.
Install peer dependencies, configure .prettierrc, and format a Nunjucks template with the enhancements.
Use a different tool like nunjucks-frontmatter-preprocessor before formatting.
Consider using a Nunjucks-specific formatter like prettier-plugin-nunjucks or unformatted.
Use twigMelodyPlugins array in .prettierrc.
Lock peer deps to those versions.
If you prefer the old behavior, pin to v1.0.0.
Run npm install --save-dev prettier-plugin-twig-enhancements.
Use "twigMelodyPlugins": ["node_modules/prettier-plugin-twig-enhancements"] in .prettierrc.
Downgrade prettier to 2.x: npm install --save-dev prettier@^2.1.2.