Class: Jekyll::Page
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#data ⇒ Object
Returns the value of attribute data.
-
#ext ⇒ Object
Returns the value of attribute ext.
-
#output ⇒ Object
Returns the value of attribute output.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(site, base, dir, name) ⇒ Page
constructor
Initialize a new Page.
-
#process(name) ⇒ Object
Extract information from the page filename
nameis the String filename of the page file. -
#render(layouts, site_payload) ⇒ Object
Add any necessary layouts to this post
layoutsis a Hash of => "layout"site_payloadis the site payload hash. -
#write(dest) ⇒ Object
Write the generated page file to the destination directory.
Methods included from Convertible
#content_type, #do_layout, #read_yaml, #render_haml_in_context, #to_s, #transform
Constructor Details
#initialize(site, base, dir, name) ⇒ Page
Initialize a new Page.
site is the Site
base is the String path to the dir is the String path between name is the String filename of the file
Returns
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll/page.rb', line 17 def initialize(site, base, dir, name) @site = site @base = base @dir = dir @name = name self.data = {} self.process(name) self.read_yaml(File.join(base, dir), name) #self.transform end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/jekyll/page.rb', line 8 def content @content end |
#data ⇒ Object
Returns the value of attribute data.
8 9 10 |
# File 'lib/jekyll/page.rb', line 8 def data @data end |
#ext ⇒ Object
Returns the value of attribute ext.
7 8 9 |
# File 'lib/jekyll/page.rb', line 7 def ext @ext end |
#output ⇒ Object
Returns the value of attribute output.
8 9 10 |
# File 'lib/jekyll/page.rb', line 8 def output @output end |
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/jekyll/page.rb', line 6 def site @site end |
Instance Method Details
#process(name) ⇒ Object
Extract information from the page filename
name is the String filename of the page file
Returns nothing
34 35 36 |
# File 'lib/jekyll/page.rb', line 34 def process(name) self.ext = File.extname(name) end |
#render(layouts, site_payload) ⇒ Object
Add any necessary layouts to this post
layouts is a Hash of => "layout"
site_payload is the site payload hash
Returns nothing
43 44 45 46 |
# File 'lib/jekyll/page.rb', line 43 def render(layouts, site_payload) payload = {"page" => self.data}.deep_merge(site_payload) do_layout(payload, layouts) end |
#write(dest) ⇒ Object
Write the generated page file to the destination directory.
dest is the String path to the destination dir
Returns nothing
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jekyll/page.rb', line 52 def write(dest) FileUtils.mkdir_p(File.join(dest, @dir)) name = @name if self.ext != "" name = @name.split(".")[0..-2].join('.') + self.ext end path = File.join(dest, @dir, name) File.open(path, 'w') do |f| f.write(self.output) end end |