@x-ror/ruby-templates 0.2.0 → 0.3.0
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 +12 -5
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# ruby-templates
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Checks and a safe formatter for Rails views in **ERB, Haml and Slim**, for CI, pre-commit hooks and editors. It is the command line of the [Ruby Templates](https://marketplace.visualstudio.com/items?itemName=x-ror.ruby-templates) VS Code extension, so the editor and CI report the same errors and format the same way.
|
|
4
|
+
|
|
5
|
+
- **No Ruby needed.** A single prebuilt binary (written in Rust): no gems, no Bundler, fast on large `app/views`.
|
|
6
|
+
- **Errors the real engines would raise**: Ruby syntax inside ERB, Haml and Slim (checked with Prism), unclosed `<%` and blocks, mismatched HTML tags, missing `alt`, Haml and Slim indentation and nesting errors, unresolved `render` partials and strict locals mismatches, with Erubi's, Rails', Haml's and Slim's own messages.
|
|
7
|
+
- **Formatting that changes only whitespace**: indentation, trailing whitespace, blank lines, the final newline. It never rewraps lines or touches Ruby, checks that the template still compiles the same, and leaves a file unchanged (saying why on stderr) when in doubt.
|
|
4
8
|
|
|
5
9
|
```sh
|
|
6
10
|
npm install --save-dev @x-ror/ruby-templates
|
|
7
|
-
|
|
8
|
-
npx ruby-templates
|
|
9
|
-
npx ruby-templates format --
|
|
11
|
+
|
|
12
|
+
npx ruby-templates check app/views # errors and warnings; exit 1 if any
|
|
13
|
+
npx ruby-templates format --check app/views # list files that would change; exit 1 if any
|
|
14
|
+
npx ruby-templates format --write app/views # format them in place
|
|
10
15
|
npx ruby-templates format --stdin-filepath app/views/users/show.html.erb < show.html.erb
|
|
11
16
|
```
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
Exit codes: 0 ok, 1 diagnostics or files that would change, 2 usage or I/O error.
|
|
19
|
+
|
|
20
|
+
The only formatter setting is the indentation width, from `.editorconfig` (`indent_size`, default 2), plus `--align-comments` for ERB comments; see [the settings](https://github.com/x-ror/vscode-ruby-templates/blob/main/docs/FORMATTER_CONFIG.md) and [the full reference](https://github.com/x-ror/vscode-ruby-templates/blob/main/docs/FEATURES.md#built-in-formatter).
|
|
14
21
|
|
|
15
22
|
The binary comes from a per-platform package (Linux x64/arm64, Windows x64) installed as an optional dependency; `RUBY_TEMPLATES_BINARY` points the wrapper at another build.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-ror/ruby-templates",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Checks and a safe, whitespace-only formatter for ERB, Haml and Slim templates, for CI and editors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -12,8 +12,15 @@
|
|
|
12
12
|
"haml",
|
|
13
13
|
"slim",
|
|
14
14
|
"rails",
|
|
15
|
-
"formatter"
|
|
15
|
+
"formatter",
|
|
16
|
+
"linter",
|
|
17
|
+
"ci",
|
|
18
|
+
"views"
|
|
16
19
|
],
|
|
20
|
+
"homepage": "https://github.com/x-ror/vscode-ruby-templates#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/x-ror/vscode-ruby-templates/issues"
|
|
23
|
+
},
|
|
17
24
|
"type": "module",
|
|
18
25
|
"bin": {
|
|
19
26
|
"ruby-templates": "bin/ruby-templates.js"
|
|
@@ -25,8 +32,8 @@
|
|
|
25
32
|
"node": ">=20.11"
|
|
26
33
|
},
|
|
27
34
|
"optionalDependencies": {
|
|
28
|
-
"@x-ror/ruby-templates-linux-x64": "0.
|
|
29
|
-
"@x-ror/ruby-templates-linux-arm64": "0.
|
|
30
|
-
"@x-ror/ruby-templates-win32-x64": "0.
|
|
35
|
+
"@x-ror/ruby-templates-linux-x64": "0.3.0",
|
|
36
|
+
"@x-ror/ruby-templates-linux-arm64": "0.3.0",
|
|
37
|
+
"@x-ror/ruby-templates-win32-x64": "0.3.0"
|
|
31
38
|
}
|
|
32
39
|
}
|