Class: Frontman::HamlRenderer
- Defined in:
- lib/frontman/renderers/haml_renderer.rb
Instance Method Summary collapse
- #compile(layout) ⇒ Object
-
#initialize ⇒ HamlRenderer
constructor
A new instance of HamlRenderer.
- #load_buffer(context) ⇒ Object
- #render_content(compiled, content, scope, _data) ⇒ Object
- #restore_buffer(context) ⇒ Object
- #save_buffer(context) ⇒ Object
Methods inherited from Renderer
Constructor Details
#initialize ⇒ HamlRenderer
Returns a new instance of HamlRenderer.
9 10 11 12 |
# File 'lib/frontman/renderers/haml_renderer.rb', line 9 def initialize Haml::Options.defaults[:format] = :html5 super end |
Instance Method Details
#compile(layout) ⇒ Object
14 15 16 |
# File 'lib/frontman/renderers/haml_renderer.rb', line 14 def compile(layout) Haml::Engine.new(layout) end |
#load_buffer(context) ⇒ Object
22 23 24 25 26 |
# File 'lib/frontman/renderers/haml_renderer.rb', line 22 def load_buffer(context) haml_locals = context.instance_variable_get(:@_haml_locals) haml_locals[:_hamlout].buffer if haml_locals end |
#render_content(compiled, content, scope, _data) ⇒ Object
18 19 20 |
# File 'lib/frontman/renderers/haml_renderer.rb', line 18 def render_content(compiled, content, scope, _data) compiled.render(scope.get_binding) { content } end |
#restore_buffer(context) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/frontman/renderers/haml_renderer.rb', line 40 def restore_buffer(context) haml_locals = context.instance_variable_get(:@_haml_locals) return unless haml_locals haml_locals[:_hamlout].buffer = @buffer context.instance_variable_set(:@_haml_locals, haml_locals) @buffer = nil end |
#save_buffer(context) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/frontman/renderers/haml_renderer.rb', line 28 def save_buffer(context) @buffer = nil haml_locals = context.instance_variable_get(:@_haml_locals) return unless haml_locals @buffer = 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 |