lib/frontman/renderers/haml_renderer.rb in frontman-ssg-0.1.0 vs lib/frontman/renderers/haml_renderer.rb in frontman-ssg-0.1.1

- old
+ new

@@ -6,10 +6,11 @@ module Frontman class HamlRenderer < Renderer def initialize Haml::Options.defaults[:format] = :html5 + @buffer = {} super end def compile(layout) Haml::Engine.new(layout) @@ -24,27 +25,26 @@ haml_locals[:_hamlout].buffer if haml_locals end def save_buffer(context) - @buffer = nil haml_locals = context.instance_variable_get(:@_haml_locals) return unless haml_locals - @buffer = haml_locals[:_hamlout].buffer + @buffer[context.buffer_hash] = haml_locals[:_hamlout].buffer # empty the buffer so we can capture everything from the new render haml_locals[:_hamlout].buffer = '' context.instance_variable_set(:@_haml_locals, haml_locals) end def restore_buffer(context) haml_locals = context.instance_variable_get(:@_haml_locals) return unless haml_locals - haml_locals[:_hamlout].buffer = @buffer + haml_locals[:_hamlout].buffer = @buffer[context.buffer_hash] context.instance_variable_set(:@_haml_locals, haml_locals) - @buffer = nil + @buffer.delete(context.buffer_hash) end end end