Fix compatibility issues with Herb#117
Open
joelhawksley wants to merge 3 commits intoruby-gettext:masterfrom
Open
Fix compatibility issues with Herb#117joelhawksley wants to merge 3 commits intoruby-gettext:masterfrom
joelhawksley wants to merge 3 commits intoruby-gettext:masterfrom
Conversation
marcoroth
added a commit
to marcoroth/herb
that referenced
this pull request
Feb 23, 2026
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
Author
|
Nevermind! marcoroth/herb#1237 fixes this upstream. |
|
FWIW, the snippet in the pull request you touched is still invalid as this is invalid Ruby: case 1
endThe following is still going to raise an error in Herb: <% case 1 %>
<% end %>I just improved the way the parser handles this to only emit 1 instead of 3 errors. |
Author
|
@marcoroth gotcha, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As part of working to integrate Herb, I ran into some issues when enabling Herb for all ERB and HTML in our application.
cc @marcoroth