Class: Dimples::Page

Inherits:
Object
  • Object
show all
Includes:
Frontable, Publishable
Defined in:
lib/dimples/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Publishable

#render, #write

Methods included from Frontable

#read_with_yaml

Constructor Details

#initialize(site, path = nil) ⇒ Page

Returns a new instance of Page.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dimples/page.rb', line 16

def initialize(site, path = nil)
  @site = site
  @extension = @site.config['file_extensions']['pages']

  if path
    @path = path
    @filename = File.basename(path, File.extname(path))
    @contents = read_with_yaml(path)
  else
    @filename = 'index'
  end
end

Instance Attribute Details

#contentsObject



29
30
31
# File 'lib/dimples/page.rb', line 29

def contents
  @contents
end

#extensionObject

Returns the value of attribute extension.



10
11
12
# File 'lib/dimples/page.rb', line 10

def extension
  @extension
end

#filenameObject

Returns the value of attribute filename.



9
10
11
# File 'lib/dimples/page.rb', line 9

def filename
  @filename
end

#layoutObject

Returns the value of attribute layout.



11
12
13
# File 'lib/dimples/page.rb', line 11

def layout
  @layout
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/dimples/page.rb', line 6

def path
  @path
end

#rendered_contentsObject

Returns the value of attribute rendered_contents.



12
13
14
# File 'lib/dimples/page.rb', line 12

def rendered_contents
  @rendered_contents
end

#templateObject

Returns the value of attribute template.



8
9
10
# File 'lib/dimples/page.rb', line 8

def template
  @template
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/dimples/page.rb', line 7

def title
  @title
end

Instance Method Details

#output_file_path(parent_path) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/dimples/page.rb', line 33

def output_file_path(parent_path)
  parts = [parent_path]

  parts << File.dirname(@path).gsub(@site.source_paths[:pages], '') unless @path.nil?
  parts << "#{@filename}.#{@extension}"

  File.join(parts)
end