Commit 8d964bf
authored
Engine: Inline comments on
## Version
herb 0.8.10 (commit `3a36f815b05b`)
## Summary
When `<% end # comment %>` closes a block opened inside a `<%= %>`
output tag, Herb appends the closing `))` *after* the comment text in
compiled Ruby. Since `#` starts a Ruby comment, the `))` become part of
the comment, leaving `__herb.h((` unclosed.
## Minimal reproduction
```erb
<%= render Foo.new do %>
hello
<% end # comment %>
```
### Actual compiled Ruby (broken)
```ruby
_buf << __herb.h((render Foo.new do; _buf << ' hello
'.freeze; end # comment ))
```
The `))` after `# comment` is commented out — parens never close.
### Expected
The `))` should be placed *before* the comment, or the comment should be
stripped:
```ruby
_buf << __herb.h((render Foo.new do; _buf << ' hello
'.freeze; end )) # comment
```
### Prism parse errors
```
- unexpected end-of-input, assuming it is closing the parent top level context (line 4)
- expected a matching `)` (line 5)
- unexpected end-of-input; expected a `)` to close the arguments (line 4)
```
## Scope
- **Affected:** `<% end # ... %>` closing a block started in `<%= %>`
(where Herb wraps in `__herb.h((...))`)
- **Not affected:** `<% end # ... %>` inside non-output `<% %>` tags —
no wrapping parens, so comment is harmless
## Workaround
Remove inline comments from `end` tags that close output-tag blocks.
---------
Signed-off-by: Joel Hawksley <joelhawksley@github.com><% end %> on output blocks produce invalid Ruby (#1363)1 parent aa12f6f commit 8d964bf
File tree
3 files changed
+15
-6
lines changed- lib/herb
- test
- engine
- snapshots/engine/engine_block_test
3 files changed
+15
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
290 | 291 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 292 | + | |
297 | 293 | | |
298 | 294 | | |
299 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments