Skip to content

Fix ERB formatting#354

Merged
kzkn merged 5 commits into
masterfrom
fix-erb-formatting
May 28, 2026
Merged

Fix ERB formatting#354
kzkn merged 5 commits into
masterfrom
fix-erb-formatting

Conversation

@kzkn
Copy link
Copy Markdown
Member

@kzkn kzkn commented Dec 24, 2025

No description provided.

@kzkn kzkn added the work in progress Not ready for merging yet. label Dec 24, 2025
kzkn added 4 commits December 24, 2025 18:07
# Conflicts:
#	spec/lib/rufo/erb_formatter_spec.rb
Two fixes for code that previously raised SyntaxError in ErbFormatter:

- yield with multiple args / parens: Ripper.sexp returns nil for these
  at top level, so process_code fell through to determine_code_wrappers
  and then to raise_syntax_error!. raise_syntax_error! calls format_code
  expecting it to raise, but Rufo::Formatter handles yield via
  sexp_unparsable_code and instead returned a formatted string, which
  was then mis-assigned as `prefix` and produced corrupt input. Use
  Rufo::Parser.sexp_unparsable_code as the Ripper.sexp fallback so
  these forms skip the wrapper logic entirely.

- `case EXPR` alone (split across ERB tags): none of the existing
  wrappers make a bare case header parse, since case requires a when
  clause. Add a `\nwhen nil\nend` suffix wrapper so the header tag is
  parseable in isolation.
@kzkn kzkn merged commit 5186ef6 into master May 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

work in progress Not ready for merging yet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant