Module: Jekyll::LayoutsExtensionWriter
Instance Method Summary collapse
Instance Method Details
#destination(dest, pagename = "index.html") ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jekyll-writer.rb', line 5 def destination(dest, pagename = "index.html") #self.is_a? Document dest = self.site.in_dest_dir(dest) # The url needs to be unescaped in order to preserve the correct filename path = self.site.in_dest_dir(dest, URL.unescape_path(self.url)) ext = File.extname(pagename) if ext == ".html" path = File.join(path, pagename) if self.url.end_with?("/") path << self.output_ext unless path.end_with?(self.output_ext) else path = path + ext # if self.url.end_with?("/") end path end |
#write(dest, pagename = "index.html") ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/jekyll-writer.rb', line 20 def write(dest, pagename = "index.html") path = destination(dest, pagename) FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'wb') do |f| f.write(self.output) end Jekyll::Hooks.trigger self, :post_write end |