Module: ActsAsTaggableOnDynamic::DynamicTagHelpers

Defined in:
lib/acts_as_taggable_on_dynamic/dynamic_tag_helpers.rb

Instance Method Summary collapse

Instance Method Details

#tag_context_add(model, options = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/acts_as_taggable_on_dynamic/dynamic_tag_helpers.rb', line 22

def tag_context_add(model, options = {})
  (:div, :id => "act-as-taggable-dynamic-new_context_form") do
    (:label, options[:label] ? options[:label] : "Contextname", :for => "act-as-taggable-dynamic-new_context_form-input") +
    (:input, "", :name => "act-as-taggable-dynamic-new_context_form-input", :type => :text, "data-model-type" => model.class.name.downcase) +
    (:a, "add", :href => "#")
  end
end

#tag_context_form(model) ⇒ Object



3
4
5
6
7
# File 'lib/acts_as_taggable_on_dynamic/dynamic_tag_helpers.rb', line 3

def tag_context_form(model)
  (:ul, :id => "#{model.class.name.downcase}_tag_context_form") do
    model.tag_context_list.collect { |context| concat((:li, "", { "data-model-type" => model.class.name.downcase, "data-context" => context, "data-value" => model.tag_list_content_on(context)})) }
  end
end

#tag_context_form_template(model) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/acts_as_taggable_on_dynamic/dynamic_tag_helpers.rb', line 9

def tag_context_form_template(model)
  (:script, :id => "#{model.class.name.downcase}_new_context_form_template", :type => "text/x-handlebars-template") do
    (:div, :class => :field) do
      (:label, model.dynamic_tag_context_label_template, :for => "#{model.class.name.downcase}_#{model.dynamic_tag_context_attribute_template}") +
      (:input, "",
                  :id => "#{model.class.name.downcase}_#{model.dynamic_tag_context_attribute_template}",
                  :name => "#{model.class.name.downcase}[#{model.dynamic_tag_context_attribute_template}]",
                  :value => "{{values}}",
                  :size => 30, :type => :text)
    end
  end
end