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
23 24 25 |
# File 'lib/nanoc/helpers/tagging.rb', line 23 def items_with_tag(tag) @items.select { |i| (i[:tags] || []).include?(tag) } end |
#link_for_tag(tag, base_url) ⇒ String
31 32 33 |
# File 'lib/nanoc/helpers/tagging.rb', line 31 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
12 13 14 15 16 17 18 |
# File 'lib/nanoc/helpers/tagging.rb', line 12 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 |