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

- old
+ new

@@ -68,23 +68,11 @@ end def errors @errors ||= [] end - - def handle_error(e) - errors.push(e) - raise if @rethrow_errors - - case e - when SyntaxError - "Liquid syntax error: #{e.message}" - else - "Liquid error: #{e.message}" - end - end - + # Render takes a hash with local variables. # # if you use the same filters over and over again consider registering them globally # with <tt>Template.register_filter</tt> # @@ -100,13 +88,15 @@ context = case args.first when Liquid::Context args.shift when Hash self.assigns.merge!(args.shift) - Context.new(self) + Context.new(assigns, registers, @rethrow_errors) when nil - Context.new(self) + Context.new(assigns, registers, @rethrow_errors) + else + raise ArgumentError, "Expect Hash or Liquid::Context as parameter" end case args.last when Hash options = args.pop @@ -121,14 +111,19 @@ 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 - @root.render(context).to_s + begin + @root.render(context).join + ensure + @errors = context.errors + end end def render!(*args) @rethrow_errors = true; render(*args) end @@ -142,9 +137,9 @@ # removes the rogue empty element at the beginning of the array tokens.shift if tokens[0] and tokens[0].empty? tokens - end + end end end