Class: Plate::View
- Inherits:
-
Object
- Object
- Plate::View
- Includes:
- BloggingHelper, MetaHelper, PartialsHelper, URLHelper
- Defined in:
- lib/plate/view.rb
Overview
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.
Instance Attribute Summary collapse
-
#page ⇒ Page
readonly
The current page (or post) being rendered.
-
#site ⇒ Site
readonly
The current site build.
Instance Method Summary collapse
-
#assets ⇒ Array
The full list of assets for this site.
- #initialize(site, page) ⇒ View constructor
-
#inspect ⇒ String
Dump out information about this view.
-
#method_missing(method, *args, &block) ⇒ Object
Allow this class to pass through to access attributes on the page.
-
#pages ⇒ Array
Reference to all pages and static files in this site.
-
#post ⇒ Post, Page
Reference to the current post, if this view is rendered with a blog post.
-
#posts ⇒ PostCollection
Reference to all posts in this site.
Methods included from URLHelper
#absolutize_paths, #sanitize_slug
Methods included from PartialsHelper
Methods included from MetaHelper
#description?, #keywords, #keywords?, #meta_description_tag, #meta_keywords_tag, #meta_tags, #title?
Methods included from BloggingHelper
#category_archives, #html_escape, #month_name, #next_post, #post_count, #post_index, #posts_for_category, #posts_for_month, #posts_for_year, #previous_post, #years_for_category
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Allow this class to pass through to access attributes on the page
62 63 64 65 66 |
# File 'lib/plate/view.rb', line 62 def method_missing(method, *args, &block) self.page.send(method, *args, &block) rescue NoMethodError super end |
Instance Attribute Details
#page ⇒ Page (readonly)
Returns The current page (or post) being rendered.
14 15 16 |
# File 'lib/plate/view.rb', line 14 def page @page end |
#site ⇒ Site (readonly)
Returns The current site build.
17 18 19 |
# File 'lib/plate/view.rb', line 17 def site @site end |
Instance Method Details
#assets ⇒ Array
The full list of assets for this site.
29 30 31 |
# File 'lib/plate/view.rb', line 29 def assets self.site.assets end |
#inspect ⇒ String
Dump out information about this view.
36 37 38 |
# File 'lib/plate/view.rb', line 36 def inspect "#<#{self.class}:0x#{object_id.to_s(16)} site=#{site ? site.source : nil} page=#{page ? page.file : nil}>" end |
#pages ⇒ Array
Reference to all pages and static files in this site.
43 44 45 |
# File 'lib/plate/view.rb', line 43 def pages self.site.pages end |
#post ⇒ Post, Page
Reference to the current post, if this view is rendered with a blog post.
50 51 52 |
# File 'lib/plate/view.rb', line 50 def post self.page end |
#posts ⇒ PostCollection
Reference to all posts in this site.
57 58 59 |
# File 'lib/plate/view.rb', line 57 def posts self.site.posts end |