reusable gallery includes; primitive, dynamic loopdir path support

This commit is contained in:
Danny Berger
2014-03-31 01:53:09 -06:00
parent 5e9da5addc
commit 52435c2e0a
5 changed files with 68 additions and 5 deletions

View File

@@ -16,7 +16,12 @@ module Jekyll
@attributes['sort'] = 'path';
markup.scan(Liquid::TagAttributes) do | key, value |
@attributes[key] = value
if 'path' == key
# path can be dynamic to support includes
@attributes['path'] = Liquid::Variable.new(value)
else
@attributes[key] = value.gsub /"(.*)"/, '\1'
end
end
if @attributes['path'].nil?
@@ -36,8 +41,10 @@ module Jekyll
context.registers[:loopdir] ||= Hash.new(0)
items = []
path = @attributes['path'].render(context)
Dir.glob(File.join(@attributes['path'], @attributes['match'])).each do |pathname|
Dir.glob(File.join(path, @attributes['match'])).each do |pathname|
if @attributes['parse']
item = {}
@@ -59,6 +66,7 @@ module Jekyll
end
item['name'] = File.basename(pathname, @attributes['match'].sub('*', ''))
item['fullname'] = path + '/' + item['name']
item['path'] = pathname
items.push item