lib/nanoc/layout_processors/haml.rb in nanoc-2.0.3 vs lib/nanoc/layout_processors/haml.rb in nanoc-2.0.4
- old
+ new
@@ -1,18 +1,38 @@
module Nanoc::LayoutProcessor::Haml
+
+ class Context
+
+ def initialize(hash)
+ hash.each_pair do |key, value|
+ instance_variable_set('@' + key.to_s, value)
+ end
+ end
+
+ def get_binding
+ binding
+ end
+
+ end
+
class HamlLayoutProcessor < Nanoc::LayoutProcessor
identifiers :haml
extensions '.haml'
- def run(layout)
+ def run(content)
nanoc_require 'haml'
- options = @page[:haml_options] || {}
- assigns = @other_assigns.merge({ :page => @page, :pages => @pages, :config => @config, :site => @site })
- options[:locals] = assigns
+ # Get options
+ options = @page.haml_options || {}
- ::Haml::Engine.new(layout, options).to_html
+ # Get assigns/locals
+ assigns = { :page => @page, :pages => @pages, :config => @config, :site => @site }
+ context = Context.new(assigns)
+
+ # Get result
+ ::Haml::Engine.new(content, options).render(context, assigns)
end
end
+
end