Skip to content

Ruby heredoc interpolation (#{...}): class names not detected by scanner #19728

@lk-umetsu

Description

@lk-umetsu

What version of Tailwind CSS are you using?

v4.2.0

What build tool (or framework if it abstracts the build tool) are you using?

tailwindcss-ruby 4.2.0

What version of Node.js are you using?

N/A

What browser are you using?

N/A

What operating system are you using?

macOS

Reproduction URL

https://github.com/lk-umetsu/tailwind-ruby-heredoc-issue

Describe your issue

Reproduces an issue in tailwindcss-ruby v4.2.0 where class names inside Ruby heredoc interpolation (#{...}) are not scanned, while the same pattern in regular strings works fine.

def width_class_heredoc(width = nil)
  <<~STYLE_CLASS
    inline-flex
    #{width || 'w-100'}
  STYLE_CLASS
end

Tailwind's scanner does not detect the string literal 'w-100' when it appears inside #{} interpolation within a heredoc, so the class is never included in the compiled tailwind.css.

This issue was not present in tailwindcss-ruby 4.1.16, where the heredoc pattern was correctly detected and the class was included in the compiled output.

The problem is specific to Ruby heredoc syntax. The following two patterns are correctly detected by the scanner:

# ✅ Detected — plain expression
def width_class(width = nil)
  width || 'w-98'
end

# ✅ Detected — regular string interpolation
def width_class(width = nil)
  "#{width || 'w-99'}"
end

# ❌ NOT detected — heredoc with interpolation
def width_class(width = nil)
  <<~STYLE_CLASS
    #{width || 'w-100'}
  STYLE_CLASS
end

To reproduce:

bundle exec tailwindcss -i input.css -o output.css
grep "w-100" output.css  # => not found
grep "w-99" output.css  # => found
grep "w-98" output.css  # => found

Expected behavior: String literals inside #{} interpolation within a heredoc should be detected as class candidates, consistent with how they are handled in regular string interpolation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions