Class: SC::RenderEngine::Haml

Inherits:
Object
  • Object
show all
Defined in:
lib/sproutcore/render_engines/haml.rb

Instance Method Summary collapse

Constructor Details

#initialize(html_context) ⇒ Haml

Returns a new instance of Haml.



12
13
14
# File 'lib/sproutcore/render_engines/haml.rb', line 12

def initialize(html_context)
  @html_context = html_context
end

Instance Method Details

#capture(*args, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/sproutcore/render_engines/haml.rb', line 29

def capture(*args, &block)
  if @html_context.respond_to?(:is_haml?) && @html_context.is_haml?
    @html_context.capture_haml(nil, &block)
  else
    block.call(*args).to_s
  end
end

#compile(input) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/sproutcore/render_engines/haml.rb', line 16

def compile(input)
  begin
    require 'haml'
  rescue
    raise "Cannot render HAML file because haml is not installed. Try running 'sudo gem install haml' and try again"
  end
  ::Haml::Engine.new(input).send(:precompiled_with_ambles, [])
end

#concat(string, binding) ⇒ Object



25
26
27
# File 'lib/sproutcore/render_engines/haml.rb', line 25

def concat(string, binding)
  eval("_hamlout", binding).push_text string
end