Set @path and @base_dir on the Layout per whether it's in the theme
This commit is contained in:
parent
d5dd423bfd
commit
2b73696d03
|
@ -39,7 +39,7 @@ module Jekyll
|
|||
filename = File.join(base, name)
|
||||
|
||||
begin
|
||||
self.content = File.read(site.in_source_dir(base, name),
|
||||
self.content = File.read(@path || site.in_source_dir(base, name),
|
||||
Utils.merged_file_read_opts(site, opts))
|
||||
if content =~ Document::YAML_FRONT_MATTER_REGEXP
|
||||
self.content = $POSTMATCH
|
||||
|
|
|
@ -29,7 +29,14 @@ module Jekyll
|
|||
@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
|
||||
|
||||
self.data = {}
|
||||
|
||||
|
@ -51,7 +58,7 @@ module Jekyll
|
|||
# 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
|
||||
@relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(@base_dir)).to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,6 +40,7 @@ module Jekyll
|
|||
@base = base
|
||||
@dir = dir
|
||||
@name = name
|
||||
@path = site.in_source_dir(base, dir, name)
|
||||
|
||||
process(name)
|
||||
read_yaml(File.join(base, dir), name)
|
||||
|
|
|
@ -373,6 +373,19 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# Public: Prefix a given path with the theme directory.
|
||||
#
|
||||
# paths - (optional) path elements to a file or directory within the
|
||||
# theme directory
|
||||
#
|
||||
# Returns a path which is prefixed with the theme root directory.
|
||||
def in_theme_dir(*paths)
|
||||
return nil unless theme
|
||||
paths.reduce(theme.root) do |base, path|
|
||||
Jekyll.sanitized_path(base, path)
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Prefix a given path with the destination directory.
|
||||
#
|
||||
# paths - (optional) path elements to a file or directory within the
|
||||
|
|
Loading…
Reference in New Issue