Repository navigation
fix(sinatra): render ERB views in erubi mode (newline fidelity) - #182
Merged
Merged
Conversation
Sinatra 4.x maps :erb to Tilt::ErubiTemplate, so real Sinatra renders views through the erubi gem's Erubi::Engine, not classic MRI ERB. rbgo's Sinatra `erb` helper compiled through go-ruby-erb's default (classic ERB) mode, so a standalone `<%= yield %>` line dropped its trailing newline (classic trim "<>") where erubi keeps it — the fidelity gap flagged in the Sinatra file-views work (#166). Select go-ruby-erb's new erb.ModeErubi (byte-identical to Erubi::Engine) for the Sinatra view render only (internal/vm/sinatra_erb.go). The standalone `require "erb"` / classic-ERB binding (internal/vm/erb.go) stays in the default ModeERB, unchanged. Prove it through the rbgo binary: the Sinatra+ERB webapp oracle gains a layout whose `<%= yield %>` stands alone on its own line (previously kept inline to dodge the classic-ERB gap). The golden was regenerated from the real sinatra gem 4.2.1 + erubi 1.13.1; rbgo now reproduces it byte-for-byte. Reverting to classic "<>" mode fails that request, confirming the fix is load-bearing. Classic ERB conformance is unchanged; sinatra_erb.go holds 100% coverage. - go-ruby-erb: v0.0.0-20260629074717 -> v0.0.0-20260706152133 (ModeErubi) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
Sinatra 4.x maps
:erbtoTilt::ErubiTemplate, so real Sinatra renders views through the erubi gem'sErubi::Engine, not classic MRI ERB. rbgo's Sinatraerbhelper compiled through go-ruby-erb's default (classic ERB) mode, so a standalone<%= yield %>line dropped its trailing newline (classic trim<>) where erubi keeps it — the fidelity gap flagged in the Sinatra file-views work (#166).Fix
Select go-ruby-erb's new
erb.ModeErubi(byte-identical toErubi::Engine, additive — go-ruby-erb PR #1) for the Sinatra view render only (internal/vm/sinatra_erb.go). The standalonerequire "erb"/ classic-ERB binding (internal/vm/erb.go) stays in the defaultModeERB, untouched.Proof (through the rbgo binary)
The Sinatra+ERB webapp oracle (
scripts/conformance/webapp) gains a layout whose<%= yield %>stands alone on its own line (route/l_standalone) — previously kept inline to dodge the classic-ERB gap. Under erubi that line keeps its trailing newline, producing a blank break between the wrapped view and the footer.<>mode fails that request, confirming the fix is load-bearing.TestERB*) unchanged;sinatra_erb.goholds 100% coverage.Dependency
go-ruby-erb:v0.0.0-20260629074717→v0.0.0-20260706152133(addsModeErubi)🤖 Generated with Claude Code