Engine: Preserve line count for ERB comment lines#1555
Engine: Preserve line count for ERB comment lines#1555joelhawksley wants to merge 7 commits intomarcoroth:mainfrom
Conversation
ERB comment lines (`<%# ... %>`) were stripped from compiled output,
producing fewer lines than Erubi. This line count difference causes
misattributed error locations and can affect error handling at template
boundaries when compiled templates are evaluated with module_eval and
a line offset.
Erubi emits a blank line for each comment, preserving line numbering:
Template: `<%# comment %>\n<% code %>`
Erubi: `\n code ;\n` (2 lines)
Herb: ` code \n` (1 line - WRONG)
Fix: Emit a blank code line (`[:code, "\n", ...]`) when processing
standalone ERB comments at line start.
|
Moving back to draft mode while I re-validate against |
|
@joelhawksley I'm happy to merge this, but just want to understand: The evaluated output was already correct and this is about more about "cosmetics", right? |
|
Actually, does Erubi really try to make an effort to keep the code on the same line as it was in the source? |
|
@marcoroth As it turns out, we didn't need this change to pass CI. We are green on |
|
@joelhawksley awesome, that's great to hear and thanks for sharing! 🎉 I agree, it would be nice to have it aligned and behave the same way. Is there a reason why you closed #1556? Doesn't that serve a similar purpose? |
|
@marcoroth I closed #1556 because I didn't need it to pass CI. I left this one open because you commented on it ❤️ I'll let you decide whether to take any of them 😄 |
|
Oh my bad then, I only commented on one because they looked so similar. But if #1556 is actually also valid on its own then lets re-open it 🙌🏼 |
ERB comment lines (
<%# ... %>) were stripped from compiled output, producing fewer lines than Erubi. This causes misattributed error locations when compiled templates are evaluated withmodule_evaland a line offset.Erubi emits a blank line for each comment, preserving line numbering. Herb stripped them entirely.
Fix: Emit a blank code line (
[:code, "\n", ...]) when processing standalone ERB comments at line start.