@herb-tools/formatter 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/herb-format.js +447 -227
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +372 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +372 -176
- package/dist/index.esm.js.map +1 -1
- package/dist/types/format-helpers.d.ts +0 -3
- package/dist/types/format-ignore.d.ts +9 -0
- package/dist/types/format-printer.d.ts +23 -0
- package/package.json +5 -5
- package/src/format-helpers.ts +0 -11
- package/src/format-ignore.ts +45 -0
- package/src/format-printer.ts +339 -170
- package/src/formatter.ts +2 -1
package/README.md
CHANGED
|
@@ -42,6 +42,16 @@ For occasional use without installing:
|
|
|
42
42
|
npx @herb-tools/formatter template.html.erb
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
### Preview Releases
|
|
46
|
+
|
|
47
|
+
Want to try unreleased features? Use pkg.pr.new to run the formatter from any commit or PR:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx https://pkg.pr.new/@herb-tools/formatter@{commit} template.html.erb
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Replace `{commit}` with a commit SHA (e.g., `0d2eabe`) or branch name (e.g., `main`). Find available previews at [pkg.pr.new/~/marcoroth/herb](https://pkg.pr.new/~/marcoroth/herb).
|
|
54
|
+
|
|
45
55
|
### Project Installation
|
|
46
56
|
|
|
47
57
|
:::code-group
|
|
@@ -234,6 +244,34 @@ herb-format --force app/views/excluded-file.html.erb
|
|
|
234
244
|
|
|
235
245
|
When using `--force` on an excluded file, the formatter will show a warning but proceed with formatting.
|
|
236
246
|
|
|
247
|
+
### Disabling Formatting for Entire Files <Badge type="info" text="v0.8.2+" />
|
|
248
|
+
|
|
249
|
+
You can disable formatting for an entire file by adding the `ignore` directive anywhere in your template:
|
|
250
|
+
|
|
251
|
+
```erb
|
|
252
|
+
<%# herb:formatter ignore %>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Example:**
|
|
256
|
+
|
|
257
|
+
:::code-group
|
|
258
|
+
```erb [ignored.html.erb]
|
|
259
|
+
<%# herb:formatter ignore %>
|
|
260
|
+
|
|
261
|
+
<div><div>This entire file will not be formatted</div></div>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
```erb [formatted.html.erb]
|
|
265
|
+
<div>
|
|
266
|
+
<div>This file will be formatted</div>
|
|
267
|
+
</div>
|
|
268
|
+
```
|
|
269
|
+
:::
|
|
270
|
+
|
|
271
|
+
::: warning Important
|
|
272
|
+
The `<%# herb:formatter ignore %>` directive must be an exact match. Extra text or spacing will prevent it from working.
|
|
273
|
+
:::
|
|
274
|
+
|
|
237
275
|
## Rewriters
|
|
238
276
|
|
|
239
277
|
The formatter supports **rewriters** that allow you to transform templates before and after formatting.
|