From 95719fa4ce071b72d1c61020f85f53f84c33589b Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Sat, 17 Aug 2013 16:24:06 +0200 Subject: [PATCH] improve error handling in include tag * Reduce condition to one-liner * Remove `self` * Implicit return value * Explicit error message for symlinks --- lib/jekyll/tags/include.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index b094b7df..29f69296 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -51,10 +51,7 @@ eos def render(context) includes_dir = File.join(context.registers[:site].source, '_includes') - error = self.validate_file(includes_dir) - unless error.nil? - return error - end + return error if error = validate_file(includes_dir) source = File.read(File.join(includes_dir, @file)) partial = Liquid::Template.parse(source) @@ -78,10 +75,8 @@ eos if !File.exists?(file) return "Included file #{@file} not found in _includes directory" elsif File.symlink?(file) - return "Included file #{@file} is a symlink" + return "Symlink #{@file} must not be included" end - - nil end end end