Skip to content

Commit

Permalink
Proxy Convertible#render_all_layouts to Renderer.place_in_layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Aug 30, 2016
1 parent 17883b7 commit b781b99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ AllCops:
Include:
- lib/**/*.rb
Exclude:
- lib/jekyll/convertible.rb
- lib/jekyll/renderer.rb
- bin/**/*
- benchmark/**/*
Expand Down
42 changes: 7 additions & 35 deletions lib/jekyll/convertible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def transform
# Returns the String extension for the output file.
# e.g. ".html" for an HTML output file.
def output_ext
Jekyll::Renderer.new(site, self).output_ext
_renderer.output_ext
end

# Determine which converter to use based on this convertible's
Expand Down Expand Up @@ -211,40 +211,7 @@ def invalid_layout?(layout)
#
# Returns nothing
def render_all_layouts(layouts, payload, info)
# recursively render layouts
layout = layouts[data["layout"]]

Jekyll.logger.warn(
"Build Warning:",
"Layout '#{data["layout"]}' requested in #{path} does not exist."
) if invalid_layout? layout

used = Set.new([layout])

# Reset the payload layout data to ensure it starts fresh for each page.
payload["layout"] = nil

while layout
Jekyll.logger.debug "Rendering Layout:", path
payload["content"] = output
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})

self.output = render_liquid(layout.content,
payload,
info,
layout.relative_path)

# Add layout to dependency tree
site.regenerator.add_dependency(
site.in_source_dir(path),
site.in_source_dir(layout.path)
)

if (layout = layouts[layout.data["layout"]])
break if used.include?(layout)
used << layout
end
end
_renderer.place_in_layouts(output, payload, info)
end

# Add any necessary layouts to this convertible document.
Expand Down Expand Up @@ -306,5 +273,10 @@ def [](property)
data[property]
end
end

private
def _renderer
@_renderer ||= Jekyll::Renderer.new(site, self)
end
end
end

0 comments on commit b781b99

Please sign in to comment.