Files
jekyll/lib/jekyll/layout.rb
Parker Moore d4e18fc979 Layout: set relative_path without using Pathname
Presently, on a Windows machine, you get an ArgumentError on Windows:

     Generating...
C:/Ruby23-x64/lib/ruby/2.3.0/pathname.rb:520:in `relative_path_from':
    different prefix: "/" and "C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/minima-1.0.1" (ArgumentError)
    from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/jekyll-3.2.0/lib/jekyll/layout.rb:61:in `relative_path'
    from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/jekyll-3.2.0/lib/jekyll/renderer.rb:161:in `place_in_layouts'
    from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/jekyll-3.2.0/lib/jekyll/renderer.rb:71:in `run'

This doesn't affect filesystems which do not use drive names.
2016-07-29 12:16:06 -07:00

61 lines
1.3 KiB
Ruby

module Jekyll
class Layout
include Convertible
# Gets the Site object.
attr_reader :site
# Gets the name of this layout.
attr_reader :name
# Gets the path to this layout.
attr_reader :path
# Gets the path to this layout relative to its base
attr_reader :relative_path
# Gets/Sets the extension of this layout.
attr_accessor :ext
# Gets/Sets the Hash that holds the metadata for this layout.
attr_accessor :data
# Gets/Sets the content of this layout.
attr_accessor :content
# Initialize a new Layout.
#
# site - The Site.
# base - The String path to the source.
# name - The String filename of the post file.
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
# Extract information from the layout filename.
#
# name - The String filename of the layout file.
#
# Returns nothing.
def process(name)
self.ext = File.extname(name)
end
end
end