Port from liquid.rb 2.2.2