2023-08-19 18:27:59 +03:00
|
|
|
# prettier-plugin-askama-template
|
|
|
|
[prettier-plugin-jinja-template](https://github.com/davidodenwald/prettier-plugin-jinja-template) but with patches to work with Askama.
|
2022-11-18 22:05:06 +03:00
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```bash
|
2023-08-19 18:29:35 +03:00
|
|
|
npm install --save-dev prettier git+https://git.fetbuk.ru/WerySkok/prettier-plugin-askama-template.git
|
2022-11-18 22:05:06 +03:00
|
|
|
```
|
|
|
|
|
2023-08-12 22:13:40 +03:00
|
|
|
Add the plugin to your `.prettierrc`:
|
|
|
|
```json
|
|
|
|
{
|
2023-08-19 18:27:59 +03:00
|
|
|
"plugins": ["prettier-plugin-askama-template"]
|
2023-08-12 22:13:40 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-11-18 22:05:06 +03:00
|
|
|
## Use
|
|
|
|
|
2023-01-06 20:32:30 +03:00
|
|
|
To format basic .html files, you'll have to override the used parser inside your `.prettierrc`:
|
2022-11-18 22:05:06 +03:00
|
|
|
```json
|
|
|
|
{
|
2022-11-18 23:22:28 +03:00
|
|
|
"overrides": [
|
|
|
|
{
|
|
|
|
"files": ["*.html"],
|
|
|
|
"options": {
|
2023-08-19 18:27:59 +03:00
|
|
|
"parser": "askama-template"
|
2022-11-18 23:22:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2022-11-18 22:05:06 +03:00
|
|
|
}
|
|
|
|
```
|
2023-01-06 20:32:30 +03:00
|
|
|
|
|
|
|
Run it on all html files in your project:
|
|
|
|
```bash
|
|
|
|
npx prettier --write **/*.html
|
2023-08-12 22:13:40 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
If you don't have a prettier config you can run the plugin with this command:
|
|
|
|
```bash
|
2023-08-19 18:27:59 +03:00
|
|
|
npx prettier --write **/*.html --plugin=prettier-plugin-askama-template
|
2023-01-06 20:32:30 +03:00
|
|
|
```
|