From 809ab5e3556c0d3a9c7da47d83ac3186ff2cfba0 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Thu, 3 Oct 2013 23:56:58 +0200 Subject: [PATCH 1/2] Move catching of liquid errors in include tags The previous code only caught render-time errors. This change makes it catch parse-time errors as well, such as unknown tags. --- lib/jekyll/tags/include.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index c8a21c2b..50092c2b 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -95,12 +95,10 @@ eos context.stack do context['include'] = parse_params(context) if @params - begin - partial.render!(context) - rescue => e - raise IncludeTagError.new e.message, File.join(INCLUDES_DIR, @file) - end + partial.render!(context) end + rescue => e + raise IncludeTagError.new e.message, File.join(INCLUDES_DIR, @file) end def validate_dir(dir, safe) From 76ada8c6728a95d90bda3b240e86b2aceb6ef760 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Fri, 4 Oct 2013 00:07:50 +0200 Subject: [PATCH 2/2] output correct path in case of liquid error in layout As with includes, an error in a layout was reported on the page that used the layout. Fix this by passing on the path of the layout that is rendered. --- lib/jekyll/convertible.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index b1dacf59..01ed0743 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -84,13 +84,13 @@ module Jekyll # info - the info for Liquid # # Returns the converted content - def render_liquid(content, payload, info) + def render_liquid(content, payload, info, path = nil) Liquid::Template.parse(content).render!(payload, info) rescue Tags::IncludeTagError => e Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}" raise e rescue Exception => e - Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{self.path}" + Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || self.path}" raise e end @@ -121,7 +121,8 @@ module Jekyll self.output = self.render_liquid(layout.content, payload, - info) + info, + File.join(self.site.config['layouts'], layout.name)) if layout = layouts[layout.data["layout"]] if used.include?(layout)