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