Add Layout#relative_path so the layout can tell us what its path is for error messages

This commit is contained in:
Parker Moore 2016-03-25 16:29:37 -07:00
parent 6aae64c985
commit a1a4b3937a
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
3 changed files with 12 additions and 4 deletions

View File

@ -215,9 +215,9 @@ module Jekyll
payload["layout"] = Utils.deep_merge_hashes(payload["layout"] || {}, layout.data)
self.output = render_liquid(layout.content,
payload,
info,
File.join(site.config['layouts_dir'], layout.name))
payload,
info,
layout.relative_path)
# Add layout to dependency tree
site.regenerator.add_dependency(

View File

@ -45,5 +45,13 @@ module Jekyll
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(site.source)).to_s
end
end
end

View File

@ -146,7 +146,7 @@ module Jekyll
layout.content,
payload,
info,
File.join(site.config['layouts_dir'], layout.name)
layout.relative_path
)
# Add layout to dependency tree