Allow empty to behave like an empty array (change needed in liquid-c)#1084
Allow empty to behave like an empty array (change needed in liquid-c)#1084er1 wants to merge 3 commits intoShopify:mainfrom
empty to behave like an empty array (change needed in liquid-c)#1084Conversation
|
@er1 This looks like a breaking-change to me. Can you test if the empty array can be filled later on..? |
|
@ashmaroli It would depend on how that filter works. I am assuming that values are immutable and that the standard filters coerce to arrays when they need arrays before performing operations. This would be in line with how enumerable drops behave. |
e145273 to
f3d17c8
Compare
| def test_empty_can_be_filled | ||
| template = Template.parse("{% assign foo = empty %}{{ foo | concat: bar }}") | ||
| assert_equal('Y', template.render!('bar' => ['Y'])) | ||
| template = Template.parse("{% assign foo = empty %}{{ foo | concat: bar | join: '--' }}") | ||
| assert_equal('A--B', template.render!('bar' => ['A', 'B'])) | ||
| template = Template.parse("{% assign foo = empty %}{% assign tar = foo | concat: bar %}{{ tar | join: '--' }}{{ tar | size }}") | ||
| assert_equal('A--B2', template.render!('bar' => ['A', 'B'])) | ||
| end |
There was a problem hiding this comment.
@ashmaroli would using the concat filter here be enough to check if arrays from the empty literal can be filled?
There was a problem hiding this comment.
Yes, that is sufficient.
|
@er1 IMO, |
|
I see. Thanks for the feedback. |
|
failing tests in df49715 depend on Shopify/liquid-c#131 |
empty to behave like an empty array (change needed in liquid-c)
This allows the
emptyliteral to act as an empty array when being used outside of comparisons.It would make empty array constructions such as
{% assign x = '' | split: '' %}more readable as{% assign x = empty %}This should not impact existing uses since empty array will get coerced into empty string if and where it is being used.
Some tests are failing and depend on: Shopify/liquid-c#131