Skip to content

Normalize splatted merge arrays like explicit attributes - #980

Open
OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/splat-empty-array-values
Open

Normalize splatted merge arrays like explicit attributes#980
OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/splat-empty-array-values

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Normalize arrays used in splatted mergeable attributes the same way as explicit attributes: flatten, convert elements to strings, remove empty values, then join. This also omits an attribute when the resulting value is empty.

Reproduction

values = ['a', nil, '', ['b', '']]
Slim::Template.new { 'p class=values' }.render(nil, values: values)
Slim::Template.new { 'p *attrs' }.render(nil, attrs: {class: values})

Before: direct output has class="a b", splatted output has class="a b ". An all-empty splat array produces class=" " rather than omitting the attribute. After: both paths match. Existing conversion of true/false to strings within merge arrays is unchanged.

Verification

  • Unmodified core/plugin suites: 415 runs / 650 assertions passing on Ruby 3.2.11 and 4.0.6; Rails integration 15 runs / 36 assertions passing on each.
  • 2,700 focused equivalence/input checks per Ruby across seeded nested/empty/nil/boolean/special-character values, three merge delimiters and class/id/custom attributes, including frozen inputs.
  • Syntax passes and no new comparative Lint offenses. No test files changed.

Compatibility / limitations

No API removal or dependency upgrade. Output intentionally changes for splatted merge arrays containing empty/nil nested values; code relying on extra whitespace or empty pieces with custom delimiters should account for this. This follows the existing direct-attribute semantics. General data/aria boolean policy (#872/#974) is unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant