mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -07:00
Fix empty? semantics and string first/last for empty strings
- nil is NOT empty (but IS blank) - matches Shopify production - String first/last returns '' for empty strings, not nil - matches ActiveSupport - Add test for nil not being empty
This commit is contained in:
@@ -160,10 +160,9 @@ module Liquid
|
||||
end
|
||||
|
||||
# Implement empty? semantics
|
||||
# Note: nil is NOT empty (but IS blank). empty? checks if a collection has zero elements.
|
||||
def liquid_empty?(value)
|
||||
case value
|
||||
when NilClass
|
||||
true
|
||||
when String, Array, Hash
|
||||
value.empty?
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user