Module: Jekyll::TagFilter
- Defined in:
- lib/jekyll-filter-by_tag.rb
Instance Method Summary collapse
Instance Method Details
#by_tag(collection, tag) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jekyll-filter-by_tag.rb', line 3 def by_tag(collection, tag) new_collection = [] if !collection.kind_of?(Array) raise TypeError, "You can only use this filter on an Array" end # puts tag if tag collection.each do |item| # puts item['tags'].inspect if ( item['tags'].kind_of?(String) && item['tags'] == '*' ) || ( item['tags'].kind_of?(Array) && item['tags'].include?(tag) ) # puts "match found for #{tag}" new_collection << item end end end # puts new_collection.inspect return new_collection end |