class Middleman::Renderers::HamlTemplate

Haml precompiles filters before the scope is even available, thus making it impossible to pass our Middleman instance in. So we have to resort to heavy hackery :(

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/middleman-core/renderers/haml.rb, line 23
def initialize(*args, &block)
  super

  @context = @options[:context] if @options.key?(:context)
end

Public Instance Methods

evaluate(scope, locals, &block) click to toggle source
# File lib/middleman-core/renderers/haml.rb, line 31
def evaluate(scope, locals, &block)
  options = {}.merge!(@options).merge!(context: @context || scope)
  if options.include?(:outvar)
    options[:buffer] = options.delete(:outvar)
    options[:save_buffer] = true
  end
  if Object.const_defined?('::Haml::Template') # haml 6+
    @engine = ::Haml::Template.new(eval_file, line, options) { data }
  else
    options[:filename] = eval_file
    options[:line] = line
    @engine = ::Haml::Engine.new(data, options)
  end
  output = @engine.render(scope, locals, &block)

  output
end
prepare() click to toggle source
# File lib/middleman-core/renderers/haml.rb, line 29
def prepare; end