From 9409a3d0348a126bd654d98eb7c0246f1e0f6921 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Thu, 19 Sep 2013 14:32:15 +0200 Subject: [PATCH] raise exceptions in include tag --- lib/jekyll/tags/include.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 2b0d82b4..4d883922 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -72,14 +72,10 @@ eos def render(context) dir = File.join(context.registers[:site].source, INCLUDES_DIR) - if error = validate_dir(dir, context.registers[:site].safe) - return error - end + validate_dir(dir, context.registers[:site].safe) file = File.join(dir, @file) - if error = validate_file(dir, context.registers[:site].safe) - return error - end + validate_file(file, context.registers[:site].safe) partial = Liquid::Template.parse(source(file)) @@ -91,15 +87,15 @@ eos def validate_dir(dir, safe) if File.symlink?(dir) && safe - "Includes directory '#{dir}' cannot be a symlink" + raise IOError.new "Includes directory '#{dir}' cannot be a symlink" end end def validate_file(file, safe) if !File.exists?(file) - "Included file '#{@file}' not found in '#{INCLUDES_DIR}' directory" + raise IOError.new "Included file '#{@file}' not found in '#{INCLUDES_DIR}' directory" elsif File.symlink?(file) && safe - "The included file '#{INCLUDES_DIR}/#{@file}' should not be a symlink" + raise IOError.new "The included file '#{INCLUDES_DIR}/#{@file}' should not be a symlink" end end