Skip to content

Commit 0ed1cab

Browse files
committed
docs: update README.md
Changes: - add link to npm package on badge - add configuration section - reformat options snippet
1 parent 90d1828 commit 0ed1cab

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

README.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,34 @@ Forked from [trivago/prettier-plugin-twig-melody](https://github.com/trivago/pre
77

88
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/zackad/prettier-plugin-twig-melody/ci.yaml?branch=master&style=for-the-badge&logo=github)
99
![GitHub License](https://img.shields.io/github/license/zackad/prettier-plugin-twig-melody?style=for-the-badge)
10-
![NPM Version](https://img.shields.io/npm/v/%40zackad%2Fprettier-plugin-twig?style=for-the-badge&logo=npm)
11-
![GitHub Tag](https://img.shields.io/github/v/tag/zackad/prettier-plugin-twig-melody?style=for-the-badge)
10+
[![NPM Version](https://img.shields.io/npm/v/%40zackad%2Fprettier-plugin-twig?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@zackad/prettier-plugin-twig)
1211

1312
---
1413

1514
This Plugin enables Prettier to format `.twig` files, as well as `.html.twig`.
1615

17-
## Install
16+
## Installation
1817

1918
```bash
2019
yarn add --dev @zackad/prettier-plugin-twig
2120
```
2221

23-
## Use
22+
## Configuration
2423

25-
```bash
26-
prettier --write "**/*.twig"
27-
```
28-
29-
In your editor, if the plugin is not automatically picked up and invoked (e.g., if you are using format on save, but no formatting is happening when you save), try adding the plugin explicitly in your Prettier configuration (e.g., `.prettierrc.json`) using the `plugins` key:
24+
Add the plugin explicitly into your Prettier configuration (e.g., `.prettierrc.json`) using the `plugins` key:
3025

3126
```json
3227
{
33-
"printWidth": 80,
34-
"tabWidth": 4,
3528
"plugins": ["@zackad/prettier-plugin-twig"]
3629
}
3730
```
3831

32+
## Usage
33+
34+
```bash
35+
./node_modules/.bin/prettier --write "**/*.twig"
36+
```
37+
3938
## Options
4039

4140
This Prettier plugin comes with some options that you can add to your Prettier configuration (e.g., `prettierrc.json`).
@@ -75,12 +74,14 @@ Choose whether to output the block name in `{% endblock %}` tags (e.g., `{% endb
7574
An array of coherent sequences of non-standard Twig tags that should be treated as belonging together. Example (inspired by [Craft CMS](https://docs.craftcms.com/v2/templating/nav.html)):
7675

7776
```json
78-
twigMultiTags: [
79-
"nav,endnav",
80-
"switch,case,default,endswitch",
81-
"ifchildren,endifchildren",
82-
"cache,endcache"
83-
]
77+
{
78+
"twigMultiTags": [
79+
"nav,endnav",
80+
"switch,case,default,endswitch",
81+
"ifchildren,endifchildren",
82+
"cache,endcache"
83+
]
84+
}
8485
```
8586

8687
Looking at the case of `nav,endnav`, this means that the Twig tags `{% nav %}` and `{% endnav %}` will be treated as a pair, and everything in between will be indented:
@@ -110,10 +111,12 @@ Note that the order matters: It has to be `"nav,endnav"`, and it must not be `"e
110111
Make custom Twig tests known to the parser.
111112

112113
```json
113-
twigTestExpressions: [
114-
"snake_case_test",
115-
"camelCaseTest"
116-
]
114+
{
115+
"twigTestExpressions": [
116+
"snake_case_test",
117+
"camelCaseTest"
118+
]
119+
}
117120
```
118121

119122
__Example__

0 commit comments

Comments
 (0)