Merge pull request #5129 from stevecheckoway/display-liquid-warnings

Merge pull request 5129
This commit is contained in:
jekyllbot 2016-07-25 10:41:54 -07:00 committed by GitHub
commit 810e411bdf
4 changed files with 26 additions and 14 deletions

View File

@ -114,16 +114,16 @@ module Jekyll
# #
# Returns the converted content # Returns the converted content
def render_liquid(content, payload, info, path) def render_liquid(content, payload, info, path)
site.liquid_renderer.file(path).parse(content).render!(payload, info) template = site.liquid_renderer.file(path).parse(content)
rescue Tags::IncludeTagError => e template.warnings.each do |e|
Jekyll.logger.error( Jekyll.logger.warn "Liquid Warning:",
"Liquid Exception:", LiquidRenderer.format_error(e, path || self.path)
"#{e.message} in #{e.path}, included in #{path || self.path}" end
) template.render!(payload, info)
raise e
# rubocop: disable RescueException # rubocop: disable RescueException
rescue Exception => e rescue Exception => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || self.path}" Jekyll.logger.error "Liquid Exception:",
LiquidRenderer.format_error(e, path || self.path)
raise e raise e
end end
# rubocop: enable RescueException # rubocop: enable RescueException

View File

@ -39,5 +39,12 @@ module Jekyll
def stats_table(n = 50) def stats_table(n = 50)
LiquidRenderer::Table.new(@stats).to_s(n) LiquidRenderer::Table.new(@stats).to_s(n)
end end
def self.format_error(e, path)
if e.is_a? Tags::IncludeTagError
return "#{e.message} in #{e.path}, included in #{path}"
end
"#{e.message} in #{path}"
end
end end
end end

View File

@ -30,6 +30,10 @@ module Jekyll
end end
end end
def warnings
@template.warnings
end
private private
def measure_bytes def measure_bytes

View File

@ -106,15 +106,16 @@ module Jekyll
# #
# Returns the content, rendered by Liquid. # Returns the content, rendered by Liquid.
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) template = site.liquid_renderer.file(path).parse(content)
rescue Tags::IncludeTagError => e template.warnings.each do |e|
Jekyll.logger.error "Liquid Exception:", Jekyll.logger.warn "Liquid Warning:",
"#{e.message} in #{e.path}, included in #{path || document.relative_path}" LiquidRenderer.format_error(e, path || document.relative_path)
raise e end
template.render!(payload, info)
# rubocop: disable RescueException # rubocop: disable RescueException
rescue Exception => e rescue Exception => e
Jekyll.logger.error "Liquid Exception:", Jekyll.logger.error "Liquid Exception:",
"#{e.message} in #{path || document.relative_path}" LiquidRenderer.format_error(e, path || document.relative_path)
raise e raise e
end end
# rubocop: enable RescueException # rubocop: enable RescueException