Class: Docks::Renderers::Haml
- Includes:
- Common::Capturable, Common::Helperable
- Defined in:
- lib/docks/renderers/haml_renderer.rb
Instance Method Summary collapse
- #capture(*args, &block) ⇒ Object
-
#initialize ⇒ Haml
constructor
A new instance of Haml.
- #render(template, locals = {}) ⇒ Object
Methods included from Common::Capturable
#concat, #content_for, #content_for?
Methods included from Common::Helperable
Methods inherited from Base
Constructor Details
#initialize ⇒ Haml
Returns a new instance of Haml.
11 12 13 14 |
# File 'lib/docks/renderers/haml_renderer.rb', line 11 def initialize require "haml" super end |
Instance Method Details
#capture(*args, &block) ⇒ Object
32 33 34 |
# File 'lib/docks/renderers/haml_renderer.rb', line 32 def capture(*args, &block) capture_haml(*args, &block) end |
#render(template, locals = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/docks/renderers/haml_renderer.rb', line 16 def render(template, locals = {}) old_buffer, @haml_buffer = @haml_buffer, nil content, layout, locals = normalize_content_and_locals(template, locals) return if content.nil? content = ::Haml::Engine.new(content).render(binding, locals) return content if layout.nil? ::Haml::Engine.new(layout).render(binding, locals) do |name| name.nil? ? content : @content_blocks[name] end ensure @haml_buffer = old_buffer end |