class Tilt::HamlTemplate

Haml template implementation. See: haml.hamptoncatlin.com/

Public Instance Methods

evaluate(scope, locals, &block) click to toggle source
Calls superclass method Template#evaluate
# File lib/tilt/haml.rb, line 22
def evaluate(scope, locals, &block)
  raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen?
  super
end
precompiled_postamble(locals) click to toggle source
# File lib/tilt/haml.rb, line 74
def precompiled_postamble(locals)
  @engine.instance_eval do
    <<-RUBY
        #{precompiled_method_return_value}
      ensure
        @haml_buffer = @haml_buffer.upper if @haml_buffer
      end
    RUBY
  end
end
precompiled_preamble(locals) click to toggle source
Calls superclass method Template#precompiled_preamble
# File lib/tilt/haml.rb, line 59
def precompiled_preamble(locals)
  local_assigns = super
  @engine.instance_eval do
    <<-RUBY
      begin
        extend Haml::Helpers
        _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
        _erbout = _hamlout.buffer
        __in_erb_template = true
        _haml_locals = locals
        #{local_assigns}
    RUBY
  end
end
precompiled_template(locals) click to toggle source
# File lib/tilt/haml.rb, line 27
def precompiled_template(locals)
  @engine.precompiled_with_ambles(
    [],
    after_preamble: <<-RUBY
      __in_erb_template = true
      _haml_locals = locals
    RUBY
  )
end
prepare() click to toggle source
# File lib/tilt/haml.rb, line 12
def prepare
  options = {}.update(@options).update(filename: eval_file, line: line)
  if options.include?(:outvar)
    options[:buffer] = options.delete(:outvar)
    options[:save_buffer] = true
  end
  @engine = ::Haml::TempleEngine.new(options)
  @engine.compile(data)
end