Convertible: ensure layouts the argument and payload the argument are set properly in the renderer
This commit is contained in:
parent
ac6bbc1906
commit
9ddc12bad8
|
@ -190,7 +190,10 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing
|
||||
def render_all_layouts(layouts, payload, info)
|
||||
_renderer.layouts = layouts
|
||||
_renderer.place_in_layouts(output, payload, info)
|
||||
ensure
|
||||
@_renderer = nil # this will allow the modifications above to disappear
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this convertible document.
|
||||
|
@ -200,11 +203,16 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def do_layout(payload, layouts)
|
||||
@_renderer = Jekyll::Renderer.new(site, self, payload)
|
||||
_renderer.run
|
||||
_renderer.tap do |renderer|
|
||||
renderer.layouts = layouts
|
||||
renderer.payload = payload
|
||||
renderer.run
|
||||
end
|
||||
|
||||
Jekyll.logger.debug "Post-Render Hooks:", self.relative_path
|
||||
Jekyll::Hooks.trigger hook_owner, :post_render, self
|
||||
ensure
|
||||
@_renderer = nil # this will allow the modifications above to disappear
|
||||
end
|
||||
|
||||
# Write the generated page file to the destination directory.
|
||||
|
|
|
@ -2,12 +2,33 @@
|
|||
|
||||
module Jekyll
|
||||
class Renderer
|
||||
attr_reader :document, :site, :payload
|
||||
attr_reader :document, :site
|
||||
attr_writer :layouts, :payload
|
||||
|
||||
def initialize(site, document, site_payload = nil)
|
||||
def initialize(site, document, site_payload = nil, layouts: nil)
|
||||
@site = site
|
||||
@document = document
|
||||
@payload = site_payload || site.site_payload
|
||||
@payload = site_payload
|
||||
@layouts = layouts
|
||||
end
|
||||
|
||||
# Fetches the payload used in Liquid rendering.
|
||||
# It can be written with #payload=(new_payload)
|
||||
# Falls back to site.site_payload if no payload is set.
|
||||
#
|
||||
# Returns a Jekyll::Drops::UnifiedPayloadDrop
|
||||
def payload
|
||||
@payload ||= site.site_payload
|
||||
end
|
||||
|
||||
# The list of layouts registered for this Renderer.
|
||||
# It can be written with #layouts=(new_layouts)
|
||||
# Falls back to site.layouts if no layouts are registered.
|
||||
#
|
||||
# Returns a Hash of String => Jekyll::Layout identified
|
||||
# as basename without the extension name.
|
||||
def layouts
|
||||
@layouts || site.layouts
|
||||
end
|
||||
|
||||
# Determine which converters to use based on this document's
|
||||
|
@ -137,7 +158,7 @@ module Jekyll
|
|||
# Returns the content placed in the Liquid-rendered layouts
|
||||
def place_in_layouts(content, payload, info)
|
||||
output = content.dup
|
||||
layout = site.layouts[document.data["layout"]]
|
||||
layout = layouts[document.data["layout"]]
|
||||
|
||||
Jekyll.logger.warn(
|
||||
"Build Warning:",
|
||||
|
@ -167,7 +188,7 @@ module Jekyll
|
|||
site.in_source_dir(layout.path)
|
||||
) if document.write?
|
||||
|
||||
if (layout = site.layouts[layout.data["layout"]])
|
||||
if (layout = layouts[layout.data["layout"]])
|
||||
break if used.include?(layout)
|
||||
used << layout
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue