From bf2e2fe08aaf001e7a5dc0ba9872e95c2dbb2d64 Mon Sep 17 00:00:00 2001
From: Robin Malfait
Notice that the `w-100` gets extracted now.
---
.../oxide/src/extractor/pre_processors/ruby.rs | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/crates/oxide/src/extractor/pre_processors/ruby.rs b/crates/oxide/src/extractor/pre_processors/ruby.rs
index 1f2221414ff4..5a3a0fabbfc7 100644
--- a/crates/oxide/src/extractor/pre_processors/ruby.rs
+++ b/crates/oxide/src/extractor/pre_processors/ruby.rs
@@ -124,7 +124,9 @@ impl PreProcessor for Ruby {
// Except for strict locals, these are defined in a `<%# locals: … %>`. Checking if
// the comment is preceded by a `%` should be enough without having to perform more
// parsing logic. Worst case we _do_ scan a few comments.
- b'#' if !matches!(cursor.prev(), b'%') => {
+ //
+ // We also want to skip interpolation syntax, which look like `#{…}`.
+ b'#' if !matches!(cursor.prev(), b'%') && !matches!(cursor.next(), b'{') => {
result[cursor.pos] = b' ';
cursor.advance();
@@ -388,6 +390,20 @@ mod tests {
Ruby::test_extract_contains(input, vec!["z-1", "z-2", "z-3"]);
}
+ // https://github.com/tailwindlabs/tailwindcss/issues/19728
+ #[test]
+ fn test_interpolated_expressions() {
+ let input = r#"
+ def width_class(width = nil)
+ <<~STYLE_CLASS
+ #{width || 'w-100'}
+ STYLE_CLASS
+ end
+ "#;
+
+ Ruby::test_extract_contains(input, vec!["w-100"]);
+ }
+
// https://github.com/tailwindlabs/tailwindcss/issues/19239
#[test]
fn test_skip_comments() {