mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 10:52:48 -07:00
liquid without the garbage
This commit is contained in:
@@ -187,9 +187,12 @@ module Liquid
|
||||
raise ArgumentError, "Expected Hash or Liquid::Context as parameter"
|
||||
end
|
||||
|
||||
output = nil
|
||||
|
||||
case args.last
|
||||
when Hash
|
||||
options = args.pop
|
||||
output = options[:output] if options[:output]
|
||||
|
||||
registers.merge!(options[:registers]) if options[:registers].is_a?(Hash)
|
||||
|
||||
@@ -205,7 +208,8 @@ module Liquid
|
||||
# render the nodelist.
|
||||
# for performance reasons we get an array back here. join will make a string out of it.
|
||||
result = with_profiling(context) do
|
||||
@root.render(context)
|
||||
output ||= self.class.output_buffer.clear
|
||||
@root.render(context, output)
|
||||
end
|
||||
result.respond_to?(:join) ? result.join : result
|
||||
rescue Liquid::MemoryError => e
|
||||
@@ -215,6 +219,10 @@ module Liquid
|
||||
end
|
||||
end
|
||||
|
||||
def self.output_buffer
|
||||
@output_buffer ||= String.new(capacity: 1024)
|
||||
end
|
||||
|
||||
def render!(*args)
|
||||
@rethrow_errors = true
|
||||
render(*args)
|
||||
|
||||
Reference in New Issue
Block a user