Sha256: 5dbe84298d87e560a73bd17a09e56747bb2e6229af6cad0c5fc2abe2ec2a5f4d

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

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(content)
      nanoc_require 'haml'

      # Get options
      options = @page.haml_options || {}

      # 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-2.0.4 lib/nanoc/layout_processors/haml.rb