diff --git a/example/server/example_servlet.rb b/example/server/example_servlet.rb
index 16f3bff..971e9c5 100644
--- a/example/server/example_servlet.rb
+++ b/example/server/example_servlet.rb
@@ -23,7 +23,7 @@ class Servlet < LiquidServlet
end
def products
- { 'products' => products_list, 'description' => description, 'section' => 'Snowboards', 'cool_products' => true}
+ { 'products' => products_list, 'more_products' => more_products_list, 'description' => description, 'section' => 'Snowboards', 'cool_products' => true}
end
private
@@ -34,6 +34,11 @@ class Servlet < LiquidServlet
{'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}]
end
+ def more_products_list
+ [{'name' => 'Arbor Catalyst', 'price' => 39900, 'description' => 'the *arbor catalyst* is an advanced drop-through for freestyle and flatground performance and versatility' },
+ {'name' => 'Arbor Fish', 'price' => 40000, 'description' => 'the *arbor fish* is a compact pin that features an extended wheelbase and time-honored teardrop shape'}]
+ end
+
def description
"List of Products ~ This is a list of products with price and description."
end
diff --git a/example/server/templates/products.liquid b/example/server/templates/products.liquid
index 374b029..779bd4d 100644
--- a/example/server/templates/products.liquid
+++ b/example/server/templates/products.liquid
@@ -16,12 +16,12 @@
-
+ {% assign all_products = products | concat: more_products %}
{{ description | split: '~' | first }}
{{ description | split: '~' | last }}
- There are currently {{products | count}} products in the {{section}} catalog
+ There are currently {{all_products | count}} products in the {{section}} catalog
{% if cool_products %}
Cool products :)
@@ -31,7 +31,7 @@
- {% for product in products %}
+ {% for product in all_products %}
-
{{product.name}}
Only {{product.price | price }}
diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb
index bbbda38..a841322 100644
--- a/lib/liquid/standardfilters.rb
+++ b/lib/liquid/standardfilters.rb
@@ -177,6 +177,10 @@ module Liquid
input.to_s + string.to_s
end
+ def concat(input, array)
+ InputIterator.new(input).concat(array)
+ end
+
# prepend a string to another
def prepend(input, string)
string.to_s + input.to_s
@@ -344,6 +348,10 @@ module Liquid
to_a.join(glue)
end
+ def concat(args)
+ to_a.concat args
+ end
+
def reverse
reverse_each.to_a
end
diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb
index 3fb9df8..10252c2 100644
--- a/test/integration/standard_filter_test.rb
+++ b/test/integration/standard_filter_test.rb
@@ -358,6 +358,12 @@ class StandardFiltersTest < Minitest::Test
assert_template_result('bcd',"{{ a | append: b}}",assigns)
end
+ def test_concat
+ assert_equal([1,2,3,4 ], @filters.concat([1,2], [3,4] ))
+ assert_equal([1,2,'a' ], @filters.concat([1,2], ['a'] ))
+ assert_equal([1,2, 10 ], @filters.concat([1,2], [ 10] ))
+ end
+
def test_prepend
assigns = {'a' => 'bc', 'b' => 'a' }
assert_template_result('abc',"{{ a | prepend: 'a'}}",assigns)