From 3a4b63f37e2aa75a008a16301fa09a70145dd047 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 16 Oct 2014 22:44:39 -0400 Subject: [PATCH] Use Expression.parse and Context#evaluate in the TableRow class. --- lib/liquid/tags/table_row.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/liquid/tags/table_row.rb b/lib/liquid/tags/table_row.rb index dde7f32..049c38a 100644 --- a/lib/liquid/tags/table_row.rb +++ b/lib/liquid/tags/table_row.rb @@ -6,10 +6,10 @@ module Liquid super if markup =~ Syntax @variable_name = $1 - @collection_name = $2 + @collection_name = Expression.parse($2) @attributes = {} markup.scan(TagAttributes) do |key, value| - @attributes[key] = value + @attributes[key] = Expression.parse(value) end else raise SyntaxError.new(options[:locale].t("errors.syntax.table_row".freeze)) @@ -17,16 +17,16 @@ module Liquid end def render(context) - collection = context[@collection_name] or return ''.freeze + collection = context.evaluate(@collection_name) or return ''.freeze - from = @attributes['offset'.freeze] ? context[@attributes['offset'.freeze]].to_i : 0 - to = @attributes['limit'.freeze] ? from + context[@attributes['limit'.freeze]].to_i : nil + from = @attributes.key?('offset'.freeze) ? context.evaluate(@attributes['offset'.freeze]).to_i : 0 + to = @attributes.key?('limit'.freeze) ? from + context.evaluate(@attributes['limit'.freeze]).to_i : nil collection = Utils.slice_collection(collection, from, to) length = collection.length - cols = context[@attributes['cols'.freeze]].to_i + cols = context.evaluate(@attributes['cols'.freeze]).to_i row = 1 col = 0