Module: Voncount::FormTagHelperExt

Defined in:
lib/voncount/voncount_form_helpers.rb

Instance Method Summary collapse

Instance Method Details

#voncount_text_area_tag(name, content = nil, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/voncount/voncount_form_helpers.rb', line 11

def voncount_text_area_tag(name, content = nil, options = {})
  options[:class] = "von-countable #{options[:class]}"
  options = options.stringify_keys

  if size = options.delete("size")
    options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
  end

  escape = options.delete("escape") { true }
  content = ERB::Util.html_escape(content) if escape

  options[:class] = "von-countable #{options[:class]}"
   :div, class: "von-count-holder" do
    (:textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)) +
    (:span, '0', class: "von-counter")
  end
end

#voncount_text_field_tag(name, value = nil, options = {}) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/voncount/voncount_form_helpers.rb', line 3

def voncount_text_field_tag(name, value = nil, options = {})
  options[:class] = "von-countable #{options[:class]}"
   :div, class: "von-count-holder" do
    tag(:input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)) +
    (:span, '0', class: "von-counter")
  end
end