Class: Redcarpet::Form::Extension::Block::Textarea
- Inherits:
-
Object
- Object
- Redcarpet::Form::Extension::Block::Textarea
- Defined in:
- lib/redcarpet/form/extension/block/textarea.rb
Overview
A textarea block
Ex: [textarea]{ value=“Hello world!” rows=“4” cols=“10” } Text box <fieldset>
<label>Text box</label>
<textarea name="123456" rows="4" cols="10">
Hello world!
</textarea>
</fieldset>
Class Method Summary collapse
Class Method Details
.default_attributes ⇒ Object
21 22 23 |
# File 'lib/redcarpet/form/extension/block/textarea.rb', line 21 def self.default_attributes { 'name' => Util.random_string, 'rows' => '3', 'value' => '' } end |
.html(matches) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/redcarpet/form/extension/block/textarea.rb', line 25 def self.html(matches) html = '<fieldset>' matches.each do |item| label = item[1] attrs = default_attributes.merge!(Util.parse_attributes(item[0])) html += "<label>#{label}</label>" unless label.empty? html += "<textarea #{Util.attributes_to_s(attrs.except('value'))}>" html += attrs['value'] unless attrs['value'].empty? html += '</textarea>' end html += '</fieldset>' end |
.pattern ⇒ Object
17 18 19 |
# File 'lib/redcarpet/form/extension/block/textarea.rb', line 17 def self.pattern /\[textarea\]([{][^}]*[}])?([^{}\]\[)]*)/ end |