Class: Jekyll::Layout

Inherits:
Object
  • Object
show all
Includes:
Convertible
Defined in:
lib/ngage/jekyll/layout.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Convertible

#[], #asset_file?, #coffeescript_file?, #converters, #do_layout, #hook_owner, #invalid_layout?, #output_ext, #place_in_layout?, #published?, #read_yaml, #render_all_layouts, #render_liquid, #render_with_liquid?, #sass_file?, #to_liquid, #to_s, #transform, #type, #validate_data!, #validate_permalink!, #write

Constructor Details

#initialize(site, base, name) ⇒ Layout

Initialize a new Layout.

site - The Site. base - The String path to the source. name - The String filename of the post file.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ngage/jekyll/layout.rb', line 33

def initialize(site, base, name)
  @site = site
  @base = base
  @name = name

  if site.theme && site.theme.layouts_path.eql?(base)
    @base_dir = site.theme.root
    @path = site.in_theme_dir(base, name)
  else
    @base_dir = site.source
    @path = site.in_source_dir(base, name)
  end
  @relative_path = @path.sub(@base_dir, "")

  self.data = {}

  process(name)
  read_yaml(base, name)
end

Instance Attribute Details

#contentObject

Gets/Sets the content of this layout.



26
27
28
# File 'lib/ngage/jekyll/layout.rb', line 26

def content
  @content
end

#dataObject

Gets/Sets the Hash that holds the metadata for this layout.



23
24
25
# File 'lib/ngage/jekyll/layout.rb', line 23

def data
  @data
end

#extObject

Gets/Sets the extension of this layout.



20
21
22
# File 'lib/ngage/jekyll/layout.rb', line 20

def ext
  @ext
end

#nameObject (readonly)

Gets the name of this layout.



11
12
13
# File 'lib/ngage/jekyll/layout.rb', line 11

def name
  @name
end

#pathObject (readonly)

Gets the path to this layout.



14
15
16
# File 'lib/ngage/jekyll/layout.rb', line 14

def path
  @path
end

#relative_pathObject (readonly)

Gets the path to this layout relative to its base



17
18
19
# File 'lib/ngage/jekyll/layout.rb', line 17

def relative_path
  @relative_path
end

#siteObject (readonly)

Gets the Site object.



8
9
10
# File 'lib/ngage/jekyll/layout.rb', line 8

def site
  @site
end

Instance Method Details

#process(name) ⇒ Object

Extract information from the layout filename.

name - The String filename of the layout file.

Returns nothing.



58
59
60
# File 'lib/ngage/jekyll/layout.rb', line 58

def process(name)
  self.ext = File.extname(name)
end