Sha256: d3504d74cfc18ad85f942c5d1a60b30d1ee3d4ad76234eaa1eded4ae55db3028

Contents?: true

Size: 671 Bytes

Versions: 5

Compression:

Stored size: 671 Bytes

Contents

module Nanoc::LayoutProcessor::ERB

  class ERBContext

    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 ERBLayoutProcessor < Nanoc::LayoutProcessor

    identifiers  :erb, :eruby
    extensions   '.erb', '.rhtml'

    def run(layout)
      nanoc_require 'erb'

      # Create context
      assigns = @other_assigns.merge({ :page => @page, :pages => @pages, :config => @config, :site => @site })
      context = ERBContext.new(assigns)

      # Get result
      ::ERB.new(layout).result(context.get_binding)
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nanoc-2.0 lib/nanoc/layout_processors/erb.rb
nanoc-2.0.1 lib/nanoc/layout_processors/erb.rb
nanoc-2.0.2 lib/nanoc/layout_processors/erb.rb
nanoc-2.0.3 lib/nanoc/layout_processors/erb.rb
nanoc-2.0.4 lib/nanoc/layout_processors/erb.rb