Sha256: 834e96c36e205acab1e744261ebcebeeb7313c03fe0251249a2488ab34a26db9
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 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 URLHelper # @return [Page] The current page (or post) being rendered. attr_reader :page # @return [Site] The current site build. attr_reader :site, :page # 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
plate-0.6.3 | lib/plate/view.rb |
plate-0.6.2 | lib/plate/view.rb |
plate-0.6.1 | lib/plate/view.rb |
plate-0.6.0 | lib/plate/view.rb |