Module: Nanoc::Helpers::Tagging
- Includes:
- HTMLEscape
- Defined in:
- lib/nanoc/helpers/tagging.rb
Overview
Instance Method Summary collapse
- #items_with_tag(tag) ⇒ Array
- #link_for_tag(tag, base_url) ⇒ String
- #tags_for(item, base_url: nil, none_text: '(none)', separator: ', ') ⇒ String
Methods included from HTMLEscape
Methods included from Capturing
Instance Method Details
#items_with_tag(tag) ⇒ Array
25 26 27 |
# File 'lib/nanoc/helpers/tagging.rb', line 25 def items_with_tag(tag) @items.select { |i| (i[:tags] || []).include?(tag) } end |
#link_for_tag(tag, base_url) ⇒ String
33 34 35 |
# File 'lib/nanoc/helpers/tagging.rb', line 33 def link_for_tag(tag, base_url) %(<a href="#{h base_url}#{h tag}" rel="tag">#{h tag}</a>) end |
#tags_for(item, base_url: nil, none_text: '(none)', separator: ', ') ⇒ String
14 15 16 17 18 19 20 |
# File 'lib/nanoc/helpers/tagging.rb', line 14 def (item, base_url: nil, none_text: '(none)', separator: ', ') if item[:tags].nil? || item[:tags].empty? none_text else item[:tags].map { |tag| base_url ? link_for_tag(tag, base_url) : tag }.join(separator) end end |