Class: Bureaucrat::Widgets::Textarea
- Defined in:
- lib/bureaucrat/widgets.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#initialize(attrs = nil) ⇒ Textarea
constructor
A new instance of Textarea.
- #render(name, value, attrs = nil) ⇒ Object
Methods inherited from Widget
#build_attrs, #has_changed?, #hidden?, id_for_label, #initialize_copy, #needs_multipart?, #value_from_formdata
Methods included from Utils
#blank_value?, #conditional_escape, #escape, #flatatt, #format_string, #make_bool, #make_float, #mark_safe, #pretty_name
Constructor Details
#initialize(attrs = nil) ⇒ Textarea
Returns a new instance of Textarea.
241 242 243 244 245 246 247 |
# File 'lib/bureaucrat/widgets.rb', line 241 def initialize(attrs=nil) # The 'rows' and 'cols' attributes are required for HTML correctness. default_attrs = {cols: '40', rows: '10'} default_attrs.merge!(attrs) if attrs super(default_attrs) end |
Instance Method Details
#render(name, value, attrs = nil) ⇒ Object
249 250 251 252 253 |
# File 'lib/bureaucrat/widgets.rb', line 249 def render(name, value, attrs=nil) value ||= '' final_attrs = build_attrs(attrs, name: name) mark_safe("<textarea#{flatatt(final_attrs)}>#{conditional_escape(value.to_s)}</textarea>") end |