Reduce Jekyll::Renderer instances during a build (#7570)
Merge pull request 7570
This commit is contained in:
parent
ffdab933b8
commit
e42c35c9ac
|
@ -78,7 +78,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the transformed contents.
|
||||
def transform
|
||||
_renderer.convert(content)
|
||||
renderer.convert(content)
|
||||
end
|
||||
|
||||
# Determine the extension depending on content_type.
|
||||
|
@ -86,7 +86,7 @@ module Jekyll
|
|||
# Returns the String extension for the output file.
|
||||
# e.g. ".html" for an HTML output file.
|
||||
def output_ext
|
||||
_renderer.output_ext
|
||||
renderer.output_ext
|
||||
end
|
||||
|
||||
# Determine which converter to use based on this convertible's
|
||||
|
@ -94,7 +94,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the Converter instance.
|
||||
def converters
|
||||
_renderer.converters
|
||||
renderer.converters
|
||||
end
|
||||
|
||||
# Render Liquid in the content
|
||||
|
@ -105,7 +105,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the converted content
|
||||
def render_liquid(content, payload, info, path)
|
||||
_renderer.render_liquid(content, payload, info, path)
|
||||
renderer.render_liquid(content, payload, info, path)
|
||||
end
|
||||
|
||||
# Convert this Convertible's data to a Hash suitable for use by Liquid.
|
||||
|
@ -191,10 +191,10 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing
|
||||
def render_all_layouts(layouts, payload, info)
|
||||
_renderer.layouts = layouts
|
||||
self.output = _renderer.place_in_layouts(output, payload, info)
|
||||
renderer.layouts = layouts
|
||||
self.output = renderer.place_in_layouts(output, payload, info)
|
||||
ensure
|
||||
@_renderer = nil # this will allow the modifications above to disappear
|
||||
@renderer = nil # this will allow the modifications above to disappear
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this convertible document.
|
||||
|
@ -204,15 +204,15 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def do_layout(payload, layouts)
|
||||
self.output = _renderer.tap do |renderer|
|
||||
renderer.layouts = layouts
|
||||
renderer.payload = payload
|
||||
self.output = renderer.tap do |doc_renderer|
|
||||
doc_renderer.layouts = layouts
|
||||
doc_renderer.payload = payload
|
||||
end.run
|
||||
|
||||
Jekyll.logger.debug "Post-Render Hooks:", relative_path
|
||||
Jekyll::Hooks.trigger hook_owner, :post_render, self
|
||||
ensure
|
||||
@_renderer = nil # this will allow the modifications above to disappear
|
||||
@renderer = nil # this will allow the modifications above to disappear
|
||||
end
|
||||
|
||||
# Write the generated page file to the destination directory.
|
||||
|
@ -241,12 +241,12 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def _renderer
|
||||
@_renderer ||= Jekyll::Renderer.new(site, self)
|
||||
def renderer
|
||||
@renderer ||= Jekyll::Renderer.new(site, self)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def no_layout?
|
||||
data["layout"] == "none"
|
||||
end
|
||||
|
|
|
@ -116,7 +116,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the output extension
|
||||
def output_ext
|
||||
@output_ext ||= Jekyll::Renderer.new(site, self).output_ext
|
||||
renderer.output_ext
|
||||
end
|
||||
|
||||
# The base filename of the document, without the file extname.
|
||||
|
@ -133,6 +133,10 @@ module Jekyll
|
|||
@basename ||= File.basename(path)
|
||||
end
|
||||
|
||||
def renderer
|
||||
@renderer ||= Jekyll::Renderer.new(site, self)
|
||||
end
|
||||
|
||||
# Produces a "cleaned" relative path.
|
||||
# The "cleaned" relative path is the relative path without the extname
|
||||
# and with the collection's directory removed as well.
|
||||
|
|
|
@ -520,7 +520,8 @@ module Jekyll
|
|||
def render_regenerated(document, payload)
|
||||
return unless regenerator.regenerate?(document)
|
||||
|
||||
document.output = Jekyll::Renderer.new(self, document, payload).run
|
||||
document.renderer.payload = payload
|
||||
document.output = document.renderer.run
|
||||
document.trigger_hooks(:post_render)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue