# prettier-plugin-django-template

> Prettier plugin for formatting Django templates.

Latest version **0.1.1** (published 2024-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-plugin-django-template
pnpm add prettier-plugin-django-template
yarn add prettier-plugin-django-template
bun add prettier-plugin-django-template
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2024-03-07 |
| First published | 2024-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 48.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stephan Fitzpatrick |
| Maintainers | knowsuchagency |
| Keywords | prettier, plugin, template, html, django |

## Links

- npm: https://www.npmjs.com/package/prettier-plugin-django-template
- Repository: https://github.com/knowsuchagency/prettier-plugin-django-template
- Homepage: https://github.com/knowsuchagency/prettier-plugin-django-template#readme
- Issues: https://github.com/knowsuchagency/prettier-plugin-django-template/issues
- npm.io page: https://npm.io/package/prettier-plugin-django-template

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2024-03-07
- 0.1.0 — 2024-03-07

## README

# prettier-plugin-django-template

Formatter plugin for Django template files.

## Install

```bash
npm install --save-dev prettier prettier-plugin-django-template
```

Add the plugin to your `.prettierrc`:
```json
{
  "plugins": ["prettier-plugin-django-template"]
}
```

## Use

To format basic .html files, you'll have to override the used parser inside your `.prettierrc`:
```json
{
  "overrides": [
    {
      "files": ["*.html"],
      "options": {
        "parser": "django-template"
      }
    }
  ]
}
```

Run it on all html files in your project:
```bash
npx prettier --write **/*.html
```

If you don't have a prettier config you can run the plugin with this command:
```bash
npx prettier --write **/*.html --plugin=prettier-plugin-django-template
```

### 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 Django tags inside `script` or `style` tags:

```html
<!-- 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](https://jinjax.scaletti.dev/) syntax.

`true` - Example:
```js
<Paginator items="{products}" />
```

`false` - Example:
```js
<Paginator items={products} />
```

| Default | CLI Override            | API Override              |
| ------- | ----------------------- | ------------------------- |
| `true`  | `--no-quote-attributes` | `quoteAttributes: <bool>` |

---
_Source: https://npm.io/package/prettier-plugin-django-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
