Sha256: 8a1d5b7526ce979b312b075c654129e01c3f847b827735cf3238a1d7448318fd

Contents?: true

Size: 507 Bytes

Versions: 2

Compression:

Stored size: 507 Bytes

Contents

module Nanoc
  class PageProxy

    def initialize(page, params={})
      @page       = page
      @do_filter  = (params[:filter] != false)
    end

    def [](key)
      if key.to_sym == :content and @do_filter
        @page.content
      elsif key.to_sym == :file
        @page.file
      elsif key.to_s.ends_with?('?')
        @page.attributes[key.to_s[0..-2].to_sym]
      else
        @page.attributes[key]
      end
    end

    def method_missing(method, *args)
      self[method]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-1.6 lib/nanoc/page_proxy.rb
nanoc-1.6.1 lib/nanoc/page_proxy.rb