Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a regression in tablerow limit parameter.

I had accidentally read slice_collection_using_each as using to as an
inclusive limit rather than exclusive, and no tests covered the offset or
limit parameters.
  • Loading branch information...
commit f5a20ff8e85b5238844f991714c2f51145585ac7 1 parent d018455
@dylanahsmith dylanahsmith authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  lib/liquid/htmltags.rb
  2. +6 −0 test/liquid/tags/html_tag_test.rb
View
2  lib/liquid/htmltags.rb
@@ -21,7 +21,7 @@ def render(context)
collection = context[@collection_name] or return ''
from = @attributes['offset'] ? context[@attributes['offset']].to_i : 0
- to = @attributes['limit'] ? from + context[@attributes['limit']].to_i - 1 : nil
+ to = @attributes['limit'] ? from + context[@attributes['limit']].to_i : nil
collection = Utils.slice_collection_using_each(collection, from, to)
View
6 test/liquid/tags/html_tag_test.rb
@@ -54,4 +54,10 @@ def test_enumerable_drop
'{% tablerow n in numbers cols:3%} {{n}} {% endtablerow %}',
'numbers' => ArrayDrop.new([1,2,3,4,5,6]))
end
+
+ def test_offset_and_limit
+ assert_template_result("<tr class=\"row1\">\n<td class=\"col1\"> 1 </td><td class=\"col2\"> 2 </td><td class=\"col3\"> 3 </td></tr>\n<tr class=\"row2\"><td class=\"col1\"> 4 </td><td class=\"col2\"> 5 </td><td class=\"col3\"> 6 </td></tr>\n",
+ '{% tablerow n in numbers cols:3 offset:1 limit:6%} {{n}} {% endtablerow %}',
+ 'numbers' => [0,1,2,3,4,5,6,7])
+ end
end # HtmlTagTest
Please sign in to comment.
Something went wrong with that request. Please try again.