You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extract classes from multi-line Ruby in Haml templates - #20635
skip_indented_block only keeps the first line of that Ruby code. On the next line it stops at the first non-whitespace character (_ => break), so the continuation lines are processed as Haml instead of Ruby: the top-level [, ] and # get replaced with spaces and candidates like bg-[#f8f5ff] and min-w-[140px] are never extracted. The same file renamed to .erb or .rb extracts them fine.
This keeps consuming a line when the previous line ended with a comma, for = and - lines, so the whole expression goes through the Ruby pre-processor. Haml comments (-# and /) are left alone, so a comment ending in a comma doesn't swallow the line after it.
We found this in a Rails app, where classes passed to multi-line render and link_to calls were missing from the build.
One fixture changes: in dst-17051.haml a href: "https://…/loco_motion#locomotion-components" continuation line no longer yields locomotion-components (the fragment of the URL), because it's now handled as a Ruby string, like it would be in a .rb file.
Test plan
Added test_multi_line_ruby to haml.rs, covering = and - continuations, a nested block, and a comment ending in a comma. Without the change it fails with bg-[#f8f5ff], min-w-[140px], text-[#0b3fa8] and w-[240px] missing.
cargo test -p tailwindcss-oxide
rustfmt --check --edition 2021 crates/oxide/src/extractor/pre_processors/haml.rs
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 2a8649f9-878f-4178-bda3-0839f4e8d287
Commits
Reviewing files that changed from the base of the PR and between e860d1f and 09cbcb0.
Files selected for processing: 1
crates/oxide/src/extractor/pre_processors/haml.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Walkthrough
The Haml preprocessor now tracks Ruby expression continuation across lines ending with commas, including when trailing whitespace or blank lines follow. It excludes comment lines and Ruby comma character literals from continuation detection. A continued expression can include its final line at end-of-input. Tests cover multiline extraction, CRLF input, and class extraction. The change also updates expected fixture markers and adds an Unreleased changelog entry.
Merge Risk: Minimal · up to 09cbc
Dedented Ruby continuations are retained for class extraction. No actionable merge-blocking risk remains from the supplied evidence.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: extracting classes from multi-line Ruby expressions in Haml templates.
Description check
The description is directly related to the changeset. It explains the Haml continuation behavior, affected Ruby expressions, tests, and fixture update.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Keep the final continuation line at EOF. · haml.rs:419
crates/oxide/src/extractor/pre_processors/haml.rs:419 Minor · Functional Correctness · Quick win
Keep the final continuation line at EOF.
If a multiline Ruby expression is the last content in a file without a trailing newline, the new continuation branch reaches EOF, but this rewind returns to the preceding newline. The final line is then processed as Haml, so classes such as bg-[#f8f5ff] are missed. Return the EOF position when the continuation reaches EOF.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 845d2efc-626d-4eff-8b76-d3a5fee0d206
Commits
Reviewing files that changed from the base of the PR and between 8cc0551 and 55144c1.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8557e17f-eeae-41e4-bfa9-10a2334fb6af
Commits
Reviewing files that changed from the base of the PR and between 55144c1 and 672b6fc.
Files selected for processing: 1
crates/oxide/src/extractor/pre_processors/haml.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
This guard ends the block before the class line. Haml preprocessing then alters the brackets, so the utility is not extracted. Bypass the indentation check while a non-comment Ruby line continues.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b717b6a2-eb0f-4f14-a3dc-bb7ac7bcbbaa
Commits
Reviewing files that changed from the base of the PR and between 846d136 and e860d1f.
Files selected for processing: 1
crates/oxide/src/extractor/pre_processors/haml.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
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
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.
Summary
In Haml, a line of Ruby can continue onto the next lines as long as each line but the last ends with a comma:
= render("card", title: "Hello", class: "bg-[#f8f5ff] min-w-[140px]")skip_indented_blockonly keeps the first line of that Ruby code. On the next line it stops at the first non-whitespace character (_ => break), so the continuation lines are processed as Haml instead of Ruby: the top-level[,]and#get replaced with spaces and candidates likebg-[#f8f5ff]andmin-w-[140px]are never extracted. The same file renamed to.erbor.rbextracts them fine.This keeps consuming a line when the previous line ended with a comma, for
=and-lines, so the whole expression goes through the Ruby pre-processor. Haml comments (-#and/) are left alone, so a comment ending in a comma doesn't swallow the line after it.We found this in a Rails app, where classes passed to multi-line
renderandlink_tocalls were missing from the build.One fixture changes: in
dst-17051.hamlahref: "https://…/loco_motion#locomotion-components"continuation line no longer yieldslocomotion-components(the fragment of the URL), because it's now handled as a Ruby string, like it would be in a.rbfile.Test plan
Added
test_multi_line_rubytohaml.rs, covering=and-continuations, a nested block, and a comment ending in a comma. Without the change it fails withbg-[#f8f5ff],min-w-[140px],text-[#0b3fa8]andw-[240px]missing.cargo test -p tailwindcss-oxide rustfmt --check --edition 2021 crates/oxide/src/extractor/pre_processors/haml.rs