Class: Malt::Engines::Haml
- Defined in:
- lib/malt/engines/haml.rb
Overview
Haml
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
Methods inherited from Abstract
#cache?, #compile, default, #initialize, register
Constructor Details
This class inherits a constructor from Malt::Engines::Abstract
Instance Method Details
#intermediate(params) ⇒ Object
51 52 53 54 55 |
# File 'lib/malt/engines/haml.rb', line 51 def intermediate(params) text = params[:text] file = params[:file] ::Haml::Engine.new(text, :filename=>file) end |
#render(params, &yld) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/malt/engines/haml.rb', line 12 def render(params, &yld) format = params[:format] case format when :html, nil render_html(params, &yld) else super(params, &yld) end end |
#render_html(params, &yld) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/malt/engines/haml.rb', line 23 def render_html(params, &yld) text = params[:text] file = params[:file] data = params[:data] engine = intermediate(params) case data when Binding html = engine.render(make_object(data), &yld) when Hash html = engine.render(Object.new, data, &yld) else if data.respond_to?(:to_hash) data = data.to_hash html = engine.render(Object.new, data, &yld) else html = engine.render(data || Object.new, &yld) end end html end |