mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 15:30:39 -07:00
uniq filter
This commit is contained in:
committed by
Florian Weingarten
parent
a8e63ff03d
commit
33e7b8e373
@@ -108,6 +108,17 @@ module Liquid
|
||||
end
|
||||
end
|
||||
|
||||
# Remove duplicate elements from an array
|
||||
# provide optional property with which to determine uniqueness
|
||||
def uniq(input, property = nil)
|
||||
ary = InputIterator.new(input)
|
||||
if property.nil?
|
||||
input.uniq
|
||||
elsif input.first.respond_to?('[]'.freeze)
|
||||
input.uniq{ |a| a[property] }
|
||||
end
|
||||
end
|
||||
|
||||
# Reverse the elements of an array
|
||||
def reverse(input)
|
||||
ary = InputIterator.new(input)
|
||||
|
||||
Reference in New Issue
Block a user