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.
Instance Method Summary collapse
-
#add_layout(layouts, site_payload) ⇒ Object
Add any necessary layouts to this post
layouts
is a Hash of => “layout”site_payload
is the site payload hash. -
#initialize(base, dir, name) ⇒ Page
constructor
Initialize a new Page.
-
#process(name) ⇒ Object
Extract information from the page filename
name
is the String filename of the page file. -
#write(dest) ⇒ Object
Write the generated page file to the destination directory.
Methods included from Convertible
#determine_content_type, #do_layout, #read_yaml, #to_s, #transform
Constructor Details
#initialize(base, dir, name) ⇒ Page
Initialize a new Page.
+base+ is the String path to the <source>
+dir+ is the String path between <source> and the file
+name+ is the String filename of the file
Returns <Page>
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jekyll/page.rb', line 15 def initialize(base, dir, name) @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.
7 8 9 |
# File 'lib/jekyll/page.rb', line 7 def content @content end |
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/jekyll/page.rb', line 7 def data @data end |
#ext ⇒ Object
Returns the value of attribute ext.
6 7 8 |
# File 'lib/jekyll/page.rb', line 6 def ext @ext end |
#output ⇒ Object
Returns the value of attribute output.
7 8 9 |
# File 'lib/jekyll/page.rb', line 7 def output @output end |
Instance Method Details
#add_layout(layouts, site_payload) ⇒ Object
Add any necessary layouts to this post
+layouts+ is a Hash of {"name" => "layout"}
+site_payload+ is the site payload hash
Returns nothing
40 41 42 43 44 45 |
# File 'lib/jekyll/page.rb', line 40 def add_layout(layouts, site_payload) self.data['url'] = @dir self.data['topleveldir'] = @dir.split("/")[1] payload = {"page" => self.data}.deep_merge(site_payload) do_layout(payload, layouts) end |
#process(name) ⇒ Object
Extract information from the page filename
+name+ is the String filename of the page file
Returns nothing
31 32 33 |
# File 'lib/jekyll/page.rb', line 31 def process(name) self.ext = File.extname(name) end |
#write(dest) ⇒ Object
Write the generated page file to the destination directory.
+dest+ is the String path to the destination dir
Returns nothing
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/jekyll/page.rb', line 51 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 |