throw IncludeTagError if error occurs in included file

fixes #5756
This commit is contained in:
Florian Thomas 2017-01-15 20:35:10 +01:00
parent becdcb5164
commit ecd04badf0
2 changed files with 15 additions and 2 deletions

View File

@ -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!"

View File

@ -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