Sha256: cfe5e1e7b9c86aa9e298b5bd1e9b0cc54d348c1dec8d01572244a11f30c8a70b
Contents?: true
Size: 1.66 KB
Versions: 14
Compression:
Stored size: 1.66 KB
Contents
module Plate # Views are utility classes that are only called within a page or layout file to be able # to access site or page specific variables. # # All default helpers as well as any custom helpers are automatically included into each # view and are accessible within your pages. class View include BloggingHelper include MetaHelper include PartialsHelper include URLHelper # @return [Page] The current page (or post) being rendered. attr_reader :page # @return [Site] The current site build. attr_reader :site # Create a new view by passing in the current {Plate::Site site} and {Plate::Page page} # instance. def initialize(site, page) @site = site @page = page end # The full list of assets for this site. # # @return [Array] def assets self.site.assets end # Dump out information about this view. # # @return [String] def inspect "#<#{self.class}:0x#{object_id.to_s(16)} site=#{site ? site.source : nil} page=#{page ? page.file : nil}>" end # Reference to all pages and static files in this site. # # @return [Array] def pages self.site.pages end # Reference to the current post, if this view is rendered with a blog post. # # @return [Post,Page] def post self.page end # Reference to all posts in this site. # # @return [PostCollection] def posts self.site.posts end # Allow this class to pass through to access attributes on the page def method_missing(method, *args, &block) self.page.send(method, *args, &block) rescue NoMethodError super end end end
Version data entries
14 entries across 14 versions & 1 rubygems