Class: Dimples::Page
- Inherits:
-
Object
- Object
- Dimples::Page
- Includes:
- Frontable, Renderable, Writeable
- Defined in:
- lib/dimples/page.rb
Overview
A class that models a single site page.
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#path ⇒ Object
Returns the value of attribute path.
-
#rendered_contents ⇒ Object
Returns the value of attribute rendered_contents.
-
#template ⇒ Object
Returns the value of attribute template.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(site, path = nil) ⇒ Page
constructor
A new instance of Page.
- #output_path(parent_path) ⇒ Object
Methods included from Renderable
#build_scope, #render, #renderer
Methods included from Writeable
Methods included from Frontable
#apply_metadata, #read_with_front_matter
Constructor Details
#initialize(site, path = nil) ⇒ Page
Returns a new instance of Page.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dimples/page.rb', line 19 def initialize(site, path = nil) @site = site @extension = 'html' @path = path if @path @filename = File.basename(@path, File.extname(@path)) @contents = read_with_front_matter(@path) else @filename = 'index' @contents = '' end end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
16 17 18 |
# File 'lib/dimples/page.rb', line 16 def contents @contents end |
#extension ⇒ Object
Returns the value of attribute extension.
14 15 16 |
# File 'lib/dimples/page.rb', line 14 def extension @extension end |
#filename ⇒ Object
Returns the value of attribute filename.
13 14 15 |
# File 'lib/dimples/page.rb', line 13 def filename @filename end |
#layout ⇒ Object
Returns the value of attribute layout.
15 16 17 |
# File 'lib/dimples/page.rb', line 15 def layout @layout end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/dimples/page.rb', line 10 def path @path end |
#rendered_contents ⇒ Object
Returns the value of attribute rendered_contents.
17 18 19 |
# File 'lib/dimples/page.rb', line 17 def rendered_contents @rendered_contents end |
#template ⇒ Object
Returns the value of attribute template.
12 13 14 |
# File 'lib/dimples/page.rb', line 12 def template @template end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/dimples/page.rb', line 11 def title @title end |
Instance Method Details
#output_path(parent_path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dimples/page.rb', line 33 def output_path(parent_path) parts = [parent_path] unless @path.nil? parts << File.dirname(@path).gsub(@site.source_paths[:pages], '') end parts << "#{@filename}.#{@extension}" File.join(parts) end |