Class: CML::Tags::Radio
Constant Summary collapse
- Template =
<<-HTML.freeze <label><input name="{{name}}" type="radio" value="{{value}}" class="{{classes}}" {{checked}}/> {{label}}</label> HTML
Instance Attribute Summary
Attributes inherited from CML::Tag
Instance Method Summary collapse
- #data ⇒ Object
-
#grouped? ⇒ Boolean
Radios should always be grouped, but for consistency with checkboxes, we check.
- #value ⇒ Object
- #wrapper(parsed) ⇒ Object
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
#data ⇒ Object
21 22 23 24 25 26 |
# File 'lib/cml/tags/radio.rb', line 21 def data super.merge({ "checked" => @attrs["checked"] ? "checked=\"checked\"" : "", "label" => @attrs["label"].to_s }) end |
#grouped? ⇒ Boolean
Radios should always be grouped, but for consistency with checkboxes, we check
9 10 11 |
# File 'lib/cml/tags/radio.rb', line 9 def grouped? @cml.parent && @cml.parent.name == "radios" end |
#value ⇒ Object
17 18 19 |
# File 'lib/cml/tags/radio.rb', line 17 def value (@attrs["value"] || @attrs["label"]).to_s end |
#wrapper(parsed) ⇒ Object
13 14 15 |
# File 'lib/cml/tags/radio.rb', line 13 def wrapper(parsed) grouped? ? parsed : super end |