Sha256: c6f7d6e7bf0f04b5ab746df67f8049963841fcb85996138d1a686ca94e8f967d
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module Nanoc2 # Nanoc2::PageProxy is a proxy object for a page (Nanoc2::Page). class PageProxy < Proxy # Requests the page attribute with the given name. +key+ can be a string # or a symbol, and it can contain a trailing question mark (which will be # stripped). def [](key) real_key = key.to_s.sub(/\?$/, '').to_sym if real_key == :mtime @obj.mtime elsif real_key == :parent @obj.parent.nil? ? nil : @obj.parent.to_proxy elsif real_key == :children @obj.children.map { |page| page.to_proxy } elsif real_key == :content # backward compatibility @obj.reps.find { |r| r.name == :default }.content elsif real_key == :path # backward compatibility @obj.reps.find { |r| r.name == :default }.web_path else super(key) end end # Returns the page representation with the given name. def reps(name) rep = @obj.reps.find { |r| r.name == name } rep.nil? ? nil : rep.to_proxy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nanoc2-2.2.3 | lib/nanoc2/base/proxies/page_proxy.rb |