diff --git a/features/rendering.feature b/features/rendering.feature index 5031ef06..fbe9ce57 100644 --- a/features/rendering.feature +++ b/features/rendering.feature @@ -12,6 +12,15 @@ Feature: Rendering Then I should get a non-zero exit-status And I should see "Liquid Exception" in the build output + Scenario: When receiving bad Liquid in included file + Given I have a _includes directory + And I have a "_includes/invalid.html" file that contains "{% INVALID %}" + And I have a "index.html" page with layout "simple" that contains "{% include invalid.html %}" + And I have a simple layout that contains "{{ content }}" + When I run jekyll build + Then I should get a non-zero exit-status + And I should see "Liquid Exception.*Unknown tag 'INVALID' in.*_includes/invalid\.html" in the build output + Scenario: Render Liquid and place in layout Given I have a "index.html" page with layout "simple" that contains "Hi there, Jekyll {{ jekyll.environment }}!" And I have a simple layout that contains "{{ content }}Ahoy, indeed!" diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index ca74087d..08843047 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -155,10 +155,14 @@ eos if cached_partial.key?(path) cached_partial[path] else - cached_partial[path] = context.registers[:site] + unparsed_file = context.registers[:site] .liquid_renderer .file(path) - .parse(read_file(path, context)) + begin + cached_partial[path] = unparsed_file.parse(read_file(path, context)) + rescue Liquid::SyntaxError => ex + raise IncludeTagError.new(ex.message, path) + end end end