Class: CML::Tags::Option

Inherits:
CML::Tag show all
Defined in:
lib/cml/tags/option.rb

Constant Summary collapse

Template =
<<-HTML.freeze
<option {{value}} {{selected}}>{{label}}</option>
HTML

Instance Attribute Summary

Attributes inherited from CML::Tag

#attrs, #cml, #tag

Instance Method Summary collapse

Methods inherited from CML::Tag

#children, #classes, #convert, #gold=, #gold?, #initialize, #instructions, #label, #legend, #name, #prefix, #raw_label, #to_html, #to_liquid, #to_s, #validate?, #validations, #wrapper_classes

Constructor Details

This class inherits a constructor from CML::Tag

Instance Method Details

#dataObject



16
17
18
19
20
21
22
# File 'lib/cml/tags/option.rb', line 16

def data
  super.merge({
    "value" => @attrs["value"] ? "value=\"#{@attrs["value"]}\"" : "", 
    "selected" => @attrs["selected"] ? "selected=\"selected\"" : "",
    "label" => (@attrs["label"] || @cml.inner_html).to_s
  })
end

#valueObject



12
13
14
# File 'lib/cml/tags/option.rb', line 12

def value
  (@attrs["value"] || @attrs["label"]).to_s
end

#wrapper(parsed) ⇒ Object



8
9
10
# File 'lib/cml/tags/option.rb', line 8

def wrapper(parsed)
  parsed
end