Commit 3fca26a
authored
This pull request improves the parser by properly matching `<% end %>`
tags to `ERBCaseNode` when no `when`/`in` clauses are present.
For the following example:
```html+erb
<% case 1 %>
<% end %>
```
The reported errors are now reduced to 1, down from 3.
**Before**
```
Errors (3 total)
1. RubyParseError at test.html.erb:1:3
case_missing_conditions: expected a `when` or `in` clause after `case`
2. MissingERBEndTagError at test.html.erb:1:0
`<% case %>` started here but never closed with an end tag. The end tag may be in a different scope.
3. ERBControlFlowScopeError at test.html.erb:2:0
`<% end %>` appears outside its control flow block. Keep ERB control flow statements together within the same HTML scope (tag, attribute, or content).
```
**After**
```
Errors (1 total)
1. RubyParseError at test.html.erb:1:3
case_missing_conditions: expected a `when` or `in` clause after `case`
```
Inspired by ruby-gettext/gettext#117
/cc @joelhawksley
1 parent dc6cf82 commit 3fca26a
4 files changed
Lines changed: 117 additions & 1 deletion
File tree
- src
- test
- parser
- snapshots/parser/case_when_test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
659 | | - | |
| 659 | + | |
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
112 | 128 | | |
113 | 129 | | |
Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments