Class: HtmlGrid::Textarea

Inherits:
Input show all
Defined in:
lib/htmlgrid/textarea.rb

Constant Summary

Constants inherited from Component

Component::CSS_CLASS, Component::CSS_ID, Component::HTML_ATTRIBUTES, Component::HTTP_HEADERS, Component::LABEL

Instance Attribute Summary collapse

Attributes inherited from NamedComponent

#name

Attributes inherited from Component

#attributes, #dojo_tooltip, #label, #model, #value

Instance Method Summary collapse

Methods inherited from Input

#init

Methods inherited from NamedComponent

#data_origin, #error?, #init, #initialize

Methods inherited from Component

#autofill?, #css_class, #css_class=, #css_id, #css_id=, #dojo_dynamic_html, #dojo_parse_on_load, #dojo_tag, #dojo_title=, #dynamic_html, #escape, #escape_symbols, #formname, #http_headers, #initialize, #label?, #onclick=, #onload=, #onsubmit=, #set_attribute, #tabindex=

Constructor Details

This class inherits a constructor from HtmlGrid::NamedComponent

Instance Attribute Details

#unescapedObject

Returns the value of attribute unescaped.



32
33
34
# File 'lib/htmlgrid/textarea.rb', line 32

def unescaped
  @unescaped
end

#value=(value) ⇒ Object (writeonly)

Sets the attribute value

Parameters:

  • value

    the value to set the attribute value to.



31
32
33
# File 'lib/htmlgrid/textarea.rb', line 31

def value=(value)
  @value = value
end

Instance Method Details

#_to_html(context, value = @value) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/htmlgrid/textarea.rb', line 43

def _to_html(context, value = @value)
  if value.is_a?(Array)
    value.collect { |elm| escape_value elm }.join("\n")
  else
    escape_value value
  end.strip
end

#escape_value(elm) ⇒ Object



39
40
41
# File 'lib/htmlgrid/textarea.rb', line 39

def escape_value(elm)
  @unescaped ? elm.to_s : escape(elm.to_s)
end

#to_html(context) ⇒ Object



33
34
35
36
37
# File 'lib/htmlgrid/textarea.rb', line 33

def to_html(context)
  context.textarea(@attributes) {
    _to_html(context, @value)
  }
end