1.4.0 • Published 11 days ago

prettier-plugin-jinja-template v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

prettier-plugin-jinja-template

Formatter plugin for jinja2 template files.

Install

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

Add the plugin to your .prettierrc:

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

Use

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

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

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-jinja-template --parser=jinja-template --write **/*.html

Ignoring Code

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

<!-- prettier-ignore-start -->
  <script>
    window.someData = {{ data | safe }}
  </script>
<!-- prettier-ignore-end -->

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

Options

This Plugin provides additional options:

Quote Attributes

Surrounds the value of html attributes with quotes. This option was introduced to support JinjaX syntax.

true - Example:

<Paginator items="{products}" />

false - Example:

<Paginator items={products} />
DefaultCLI OverrideAPI Override
true--no-quote-attributesquoteAttributes: <bool>
1.4.0

11 days ago

1.3.3

2 months ago

1.3.2

5 months ago

1.2.0

7 months ago

1.3.1

7 months ago

1.3.0

7 months ago

1.1.0

8 months ago

1.0.0

9 months ago

0.3.0

1 year ago

0.5.0

12 months ago

0.4.0

1 year ago

0.1.0

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago