diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 2e4a1174..fc0907a9 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -328,14 +328,23 @@ module Jekyll def as_liquid(item) case item - when String, Numeric, true, false, nil - item.to_liquid when Hash - Hash[item.map { |k, v| [as_liquid(k), as_liquid(v)] }] + pairs = item.map { |k, v| as_liquid([k, v]) } + Hash[pairs] when Array item.map{ |i| as_liquid(i) } - else - item.respond_to?(:to_liquid) ? as_liquid(item.to_liquid) : item + else # simple type + if item.respond_to?(:to_liquid) + liquidated = item.to_liquid + # prevent infinite recursion + if liquidated == item + item + else + as_liquid(liquidated) + end + else + item + end end end end