improve error handling in include tag

* Reduce condition to one-liner
* Remove `self`
* Implicit return value
* Explicit error message for symlinks
This commit is contained in:
maul.esel 2013-08-17 16:24:06 +02:00
parent b5d25427e5
commit 95719fa4ce
1 changed files with 2 additions and 7 deletions

View File

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