Skip to content

Comments

Fix compatibility issues with Herb#117

Open
joelhawksley wants to merge 3 commits intoruby-gettext:masterfrom
joelhawksley:herb-compat
Open

Fix compatibility issues with Herb#117
joelhawksley wants to merge 3 commits intoruby-gettext:masterfrom
joelhawksley:herb-compat

Conversation

@joelhawksley
Copy link

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

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
@joelhawksley
Copy link
Author

Nevermind! marcoroth/herb#1237 fixes this upstream.

@marcoroth
Copy link

marcoroth commented Feb 23, 2026

FWIW, the snippet in the pull request you touched is still invalid as this is invalid Ruby:

case 1
end

The 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.

@joelhawksley joelhawksley reopened this Feb 23, 2026
@joelhawksley
Copy link
Author

@marcoroth gotcha, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants