Sha256: 917871d327f8fab4e710578598dba8de932c267d695883a22ddfd621142de37d
Contents?: true
Size: 835 Bytes
Versions: 1
Compression:
Stored size: 835 Bytes
Contents
module Jekyll class IncludeTag < Liquid::Tag def initialize(tag_name, file, tokens) super @file = file.strip end def render(context) if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./ return "Include file '#{@file}' contains invalid characters or sequences" end Dir.chdir(File.join(Jekyll.source, '_includes')) do choices = Dir['**/*'].reject { |x| File.symlink?(x) } 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" end end end end end Liquid::Template.register_tag('include', Jekyll::IncludeTag)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tristandunn-jekyll-0.3.0 | lib/jekyll/tags/include.rb |