Module: E9Tags::Helper

Defined in:
lib/e9_tags/helper.rb

Instance Method Summary collapse

Instance Method Details

#humanize_context(*context_and_is_private) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/e9_tags/helper.rb', line 12

def humanize_context(*context_and_is_private)
  context, is_private = context_and_is_private

  context = E9Tags.unescape_context(context)

  if is_private && context !~ /#{E9Tags::PRIVATE_TAG_SUFFIX_REGEX}$/
    context << E9Tags::PRIVATE_TAG_SUFFIX 
  end

  context
end

#tag_list(resource, highlighted_tag = nil, options = {}) ⇒ Object



24
25
26
# File 'lib/e9_tags/helper.rb', line 24

def tag_list(resource, highlighted_tag = nil, options = {})
  _tag_list(resource.tags(options), highlighted_tag) if resource.respond_to?(:tags)
end

#tag_list_with_context(resource, highlighted_tag = nil, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/e9_tags/helper.rb', line 28

def tag_list_with_context(resource, highlighted_tag = nil, options = {})
  if resource.respond_to?(:tagging_contexts)

    # by default, we don't want to show all tags
    options[:show_all] = false if options.blank?

    (:div, :class => 'tag-lists') do
      ''.html_safe.tap do |html|
        resource.tagging_contexts(options).each do |context|
          str = ''.html_safe
          str.safe_concat (:div, "#{humanize_context(E9Tags.unescape_context(context))}:", :class => 'heading')
          str.safe_concat _tag_list(resource.tag_list_on(context), highlighted_tag)

          html.safe_concat (:div, str.html_safe, :class => 'tag-context-list')
        end
      end
    end
  end
end

#tag_template(object, tag = "__TAG__", context = "__CONTEXT__", u_context = "__UCONTEXT__") ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/e9_tags/helper.rb', line 3

def tag_template(object, tag = "__TAG__", context = "__CONTEXT__", u_context = "__UCONTEXT__")
  render('e9_tags/template', {
    :tag        => tag,
    :context    => context,
    :u_context  => u_context,
    :class_name => object.class.name.underscore
  })
end