Class: Middleman::Renderers::HamlTemplate

Inherits:
Tilt::HamlTemplate
  • Object
show all
Defined in:
lib/middleman-core/renderers/haml.rb

Overview

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 :(

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ HamlTemplate

Returns a new instance of HamlTemplate.



23
24
25
26
27
# File 'lib/middleman-core/renderers/haml.rb', line 23

def initialize(*args, &block)
  super

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

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/middleman-core/renderers/haml.rb', line 32

def evaluate(scope, locals, &block)
  options = {}.merge!(@options).merge!(filename: eval_file, line: line, context: @context || scope)
  @engine = ::Haml::Engine.new(data, options)
  output = @engine.render(scope, locals, &block)

  output
end

#prepareObject



29
30
# File 'lib/middleman-core/renderers/haml.rb', line 29

def prepare
end