2.0.2 • Published 10 months ago

@koha-community/prettier-plugin-template-toolkit v2.0.2

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
10 months ago

prettier-plugin-template-toolkit

Formatter plugin for Template::Toolkit template files.

This is a fork of prettier-plugin-jinja-template, we are very grateful to the original author!

Install

npm install --save-dev prettier prettier-plugin-template-toolkit

Add the plugin to your .prettierrc:

{
  "plugins": ["prettier-plugin-template-toolkit"]
}

Use

To format basic .html files, you'll have to override the used parser inside your .prettierrc:

{
  "overrides": [
    {
      "files": ["*.html"],
      "options": {
        "parser": "template-toolkit"
      }
    }
  ]
}

Run it on all HTML files in your project:

npx prettier --write **/*.html

If you don't have a prettier config you can run the plugin with this command:

npx prettier --plugin=prettier-plugin-template-toolkit --parser=template-toolkit --write **/*.html

Ignoring Code

Using range ignores is the best way to tell prettier to ignore part of files. Most of the time this is necessary for Template::Toolkit tags inside script or style tags:

<!-- prettier-ignore-start -->
  <script>
    window.someData = [% data %]
  </script>
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->
  <style>
    :root { --accent-color: [% theme_accent_color %] }
  </style>
<!-- prettier-ignore-end -->

Or using Template::Toolkit comments:

[%# prettier-ignore-start %]
  <script>
    window.someData = [% data %]
  </script>
[%# prettier-ignore-end %]

[%# prettier-ignore-start %]
  <style>
    :root { --accent-color: [% theme_accent_color %] }
  </style>
[%# prettier-ignore-end %]}
ansi-escapesansi-regexansi-stylesanymatchargparseasyncbabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbabel-preset-jestbalanced-matchbinary-extensionsbrace-expansionbracesbrowserslistbs-loggerbserbuffer-fromcallsitescamelcasecaniuse-litechalkchar-regexchokidarci-infocjs-module-lexercliuicocollect-v8-coveragecolor-convertcolor-namecommanderconcat-mapconvert-source-mapcreate-jestcross-spawndebugdedentdeepmergedetect-newlinediff-sequencesejselectron-to-chromiumemitteryemoji-regexerror-exescaladeescape-string-regexpesprimaexecaexitexpectfast-json-stable-stringifyfb-watchmanfilelistfill-rangefind-upfs-readdir-recursivefs.realpathfunction-bindgensyncget-caller-fileget-package-typeget-streamglobglob-parentglobalsgraceful-fshas-flaghasownhtml-escaperhuman-signalsimport-localimurmurhashinflightinheritsis-arrayishis-binary-pathis-core-moduleis-extglobis-fullwidth-code-pointis-generator-fnis-globis-numberis-streamisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjakejest-changed-filesjest-circusjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-nodejest-get-typejest-haste-mapjest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-tokensjs-yamljsescjson-parse-even-better-errorsjson5kleurlevenlines-and-columnslocate-pathlodash.memoizelru-cachemake-dirmake-errormakeerrormerge-streammicromatchmimic-fnminimatchmsnatural-comparenode-int64node-releasesnormalize-pathnpm-run-pathonceonetimep-limitp-locatep-tryparse-jsonpath-existspath-is-absolutepath-keypath-parsepicocolorspicomatchpifypiratespkg-dirpretty-formatpromptspure-randreact-isreaddirprequire-directoryresolveresolve-cwdresolve-fromresolve.exportssemvershebang-commandshebang-regexsignal-exitsisteransislashsource-mapsource-map-supportsprintf-jsstack-utilsstring-lengthstring-widthstrip-ansistrip-bomstrip-final-newlinestrip-json-commentssupports-colorsupports-preserve-symlinks-flagtest-excludetmplto-regex-rangetype-detecttype-festundici-typesupdate-browserslist-dbv8-to-istanbulwalkerwhichwrap-ansiwrappywrite-file-atomicy18nyallistyargsyargs-parseryocto-queue
2.0.2

10 months ago

2.0.1

11 months ago