rubocop: fix code style

This commit is contained in:
Anatoliy Yastreb 2016-06-25 15:22:36 +03:00
parent 6dd3cc21c4
commit 3ccc91430f
1 changed files with 26 additions and 19 deletions

View File

@ -38,21 +38,21 @@ module Jekyll
payload["paginator"] = document.pager.to_liquid payload["paginator"] = document.pager.to_liquid
end end
if document.is_a?(Document) && document.collection.label == 'posts' if document.is_a?(Document) && document.collection.label == "posts"
payload['site']['related_posts'] = document.related_posts payload["site"]["related_posts"] = document.related_posts
else else
payload['site']['related_posts'] = nil payload["site"]["related_posts"] = nil
end end
# render and transform content (this becomes the final content of the object) # render and transform content (this becomes the final content of the object)
payload['highlighter_prefix'] = converters.first.highlighter_prefix payload["highlighter_prefix"] = converters.first.highlighter_prefix
payload['highlighter_suffix'] = converters.first.highlighter_suffix payload["highlighter_suffix"] = converters.first.highlighter_suffix
Jekyll.logger.debug "Pre-Render Hooks:", document.relative_path Jekyll.logger.debug "Pre-Render Hooks:", document.relative_path
document.trigger_hooks(:pre_render, payload) document.trigger_hooks(:pre_render, payload)
info = { info = {
:registers => { :site => site, :page => payload['page'] } :registers => { :site => site, :page => payload["page"] }
} }
output = document.content output = document.content
@ -88,7 +88,9 @@ module Jekyll
begin begin
converter.convert output converter.convert output
rescue => e rescue => e
Jekyll.logger.error "Conversion error:", "#{converter.class} encountered an error while converting '#{document.relative_path}':" Jekyll.logger.error "Conversion error:",
"#{converter.class} encountered an error while "\
"converting '#{document.relative_path}':"
Jekyll.logger.error("", e.to_s) Jekyll.logger.error("", e.to_s)
raise e raise e
end end
@ -106,12 +108,16 @@ module Jekyll
def render_liquid(content, payload, info, path = nil) def render_liquid(content, payload, info, path = nil)
site.liquid_renderer.file(path).parse(content).render!(payload, info) site.liquid_renderer.file(path).parse(content).render!(payload, info)
rescue Tags::IncludeTagError => e rescue Tags::IncludeTagError => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}, included in #{path || document.relative_path}" Jekyll.logger.error "Liquid Exception:",
"#{e.message} in #{e.path}, included in #{path || document.relative_path}"
raise e raise e
# rubocop: disable RescueException
rescue Exception => e rescue Exception => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || document.relative_path}" Jekyll.logger.error "Liquid Exception:",
"#{e.message} in #{path || document.relative_path}"
raise e raise e
end end
# rubocop: enable RescueException
# Checks if the layout specified in the document actually exists # Checks if the layout specified in the document actually exists
# #
@ -132,16 +138,20 @@ module Jekyll
output = content.dup output = content.dup
layout = site.layouts[document.data["layout"]] layout = site.layouts[document.data["layout"]]
Jekyll.logger.warn("Build Warning:", "Layout '#{document.data["layout"]}' requested in #{document.relative_path} does not exist.") if invalid_layout? layout Jekyll.logger.warn(
"Build Warning:",
"Layout '#{document.data["layout"]}' requested in "\
"#{document.relative_path} does not exist."
) if invalid_layout? layout
used = Set.new([layout]) used = Set.new([layout])
# Reset the payload layout data to ensure it starts fresh for each page. # Reset the payload layout data to ensure it starts fresh for each page.
payload["layout"] = nil payload["layout"] = nil
while layout while layout
payload['content'] = output payload["content"] = output
payload['layout'] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
output = render_liquid( output = render_liquid(
layout.content, layout.content,
@ -156,12 +166,9 @@ module Jekyll
site.in_source_dir(layout.path) site.in_source_dir(layout.path)
) if document.write? ) if document.write?
if layout = site.layouts[layout.data["layout"]] if (layout = site.layouts[layout.data["layout"]])
if used.include?(layout) break if used.include?(layout)
layout = nil # avoid recursive chain used << layout
else
used << layout
end
end end
end end