Class: Middleman::Renderers::HamlTemplate
- Inherits:
-
Tilt::HamlTemplate
- Object
- Tilt::HamlTemplate
- Middleman::Renderers::HamlTemplate
- Defined in:
- middleman-core/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
- #evaluate(scope, locals, &block) ⇒ Object
-
#initialize(*args, &block) ⇒ HamlTemplate
constructor
A new instance of HamlTemplate.
- #prepare ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ HamlTemplate
23 24 25 26 27 |
# File 'middleman-core/lib/middleman-core/renderers/haml.rb', line 23 def initialize(*args, &block) super @context = [:context] if .key?(:context) end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'middleman-core/lib/middleman-core/renderers/haml.rb', line 31 def evaluate(scope, locals, &block) = {}.merge!().merge!(filename: eval_file, line: line, context: @context || scope) if .include?(:outvar) [:buffer] = .delete(:outvar) [:save_buffer] = true end @engine = ::Haml::Engine.new(data, ) output = @engine.render(scope, locals, &block) output end |
#prepare ⇒ Object
29 |
# File 'middleman-core/lib/middleman-core/renderers/haml.rb', line 29 def prepare; end |