lib/jekyll/layout.rb in jekyll-3.1.6 vs lib/jekyll/layout.rb in jekyll-3.2.0.pre.beta1

- old
+ new

@@ -27,12 +27,19 @@ # name - The String filename of the post file. def initialize(site, base, name) @site = site @base = base @name = name - @path = site.in_source_dir(base, 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 + self.data = {} process(name) read_yaml(base, name) end @@ -42,8 +49,16 @@ # name - The String filename of the layout file. # # Returns nothing. def process(name) self.ext = File.extname(name) + end + + # The path to the layout, relative to the site source. + # + # Returns a String path which represents the relative path + # from the site source to this layout + def relative_path + @relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(@base_dir)).to_s end end end