lib/liquid/template.rb in liquid-1.9.0 vs lib/liquid/template.rb in liquid-2.0.0

- old
+ new

@@ -81,11 +81,11 @@ # * <tt>filters</tt> : array with local filters # * <tt>registers</tt> : hash with register variables. Those can be accessed from # filters and tags and might be useful to integrate liquid more with its host application # def render(*args) - return '' if @root.nil? + return '' if @root.nil? context = case args.first when Liquid::Context args.shift when Hash @@ -105,21 +105,21 @@ self.registers.merge!(options[:registers]) end if options[:filters] context.add_filters(options[:filters]) - end + end + when Module context.add_filters(args.pop) when Array context.add_filters(args.pop) end - - - # render the nodelist. - # for performance reasons we get a array back here. to_s will make a string out of it + begin + # render the nodelist. + # for performance reasons we get a array back here. join will make a string out of it @root.render(context).join ensure @errors = context.errors end end @@ -129,10 +129,11 @@ end private # Uses the <tt>Liquid::TemplateParser</tt> regexp to tokenize the passed source - def tokenize(source) + def tokenize(source) + source = source.source if source.respond_to?(:source) return [] if source.to_s.empty? tokens = source.split(TemplateParser) # removes the rogue empty element at the beginning of the array tokens.shift if tokens[0] and tokens[0].empty?