Prettier plugin for formatting Twig templates, including .twig, .html.twig, and .melody.twig files. Version 1.0.1 is the current stable release. Integrates with the standard Prettier workflow but requires manual plugin configuration in some editors. Key differentiators: supports Melody component framework, offers Twig-specific options like twigSingleQuote, twigAlwaysBreakObjects, twigFollowOfficialCodingStandards, and twigMultiTags for custom tag pairs. Low maintenance activity on GitHub.
npm install prettier-plugin-twigVerified import paths — ran on the pinned version, not inferred.
Installs the plugin, adds configuration to .prettierrc.json, and runs Prettier on .melody.twig files showing before/after formatting.
Add '"plugins": ["./node_modules/prettier-plugin-twig-melody"]' to .prettierrc.json
Use require() or rely on Prettier's internal loading; do not use ES import statements for this package.
Place twigSingleQuote, twigAlwaysBreakObjects, etc., directly in the Prettier config JSON.
Always install and reference 'prettier-plugin-twig-melody' from npm, not 'prettier-plugin-twig'.
Install the correct package: npm install --save-dev prettier-plugin-twig-melody ; then add '"plugins": ["./node_modules/prettier-plugin-twig-melody"]' to .prettierrc.json
Add the plugin path to .prettierrc.json 'plugins' array; ensure Prettier >= 2.0 is installed
Use an absolute path or verify the relative path from the project root: '"plugins": ["./node_modules/prettier-plugin-twig-melody"]'