Skip to content

Commit

Permalink
Fixes include tag patch for jekyll#176 , @file variable is no longer …
Browse files Browse the repository at this point in the history
…modified
  • Loading branch information
c-abird committed Jul 4, 2012
1 parent d316894 commit d9a4615
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/jekyll/tags/include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ def initialize(tag_name, file, tokens)
end

def render(context)
@file = context[@file] if context.has_key?(@file)
file = context[@file] || @file
includes_dir = File.join(context.registers[:site].source, '_includes')

if File.symlink?(includes_dir)
return "Includes directory '#{includes_dir}' cannot be a symlink"
end

if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
return "Include file '#{@file}' contains invalid characters or sequences"
if file !~ /^[a-zA-Z0-9_\/\.-]+$/ || file =~ /\.\// || file =~ /\/\./
return "Include file '#{file}' contains invalid characters or sequences"
end

Dir.chdir(includes_dir) do
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
if choices.include?(@file)
source = File.read(@file)
if choices.include?(file)
source = File.read(file)
partial = Liquid::Template.parse(source)
context.stack do
partial.render(context)
end
else
"Included file '#{@file}' not found in _includes directory"
"Included file '#{file}' not found in _includes directory"
end
end
end
Expand Down

0 comments on commit d9a4615

Please sign in to comment.