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
-
#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. -
#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. -
#write(dest_prefix, dest_suffix = nil) ⇒ Object
dest_prefix
is the String path to the destination dirdest_suffix
is a suffix path to the destination dir.
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
#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 |
#render(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 |
# File 'lib/jekyll/page.rb', line 40 def render(layouts, site_payload) payload = {"page" => self.data}.deep_merge(site_payload) do_layout(payload, layouts) end |
#write(dest_prefix, dest_suffix = nil) ⇒ Object
dest_prefix
is the String path to the destination dir
+dest_suffix+ is a suffix path to the destination dir
Returns nothing
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jekyll/page.rb', line 50 def write(dest_prefix, dest_suffix = nil) dest = File.join(dest_prefix, @dir) dest = File.join(dest, dest_suffix) if dest_suffix FileUtils.mkdir_p(dest) name = @name if self.ext != "" name = @name.split(".")[0..-2].join('.') + self.ext end path = File.join(dest, name) File.open(path, 'w') do |f| f.write(self.output) end end |