Class: CML::Tags::Radios

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

Constant Summary collapse

Template =
<<-HTML.freeze
{{legend}}
  {{content}}
HTML

Constants included from CML::TagLogic

CML::TagLogic::And, CML::TagLogic::AndPhraseExp, CML::TagLogic::CombinatorDefault, CML::TagLogic::CombinatorDict, CML::TagLogic::CombinatorExp, CML::TagLogic::GroupExp, CML::TagLogic::Or, CML::TagLogic::OrCombinatorExp, CML::TagLogic::PrecedenceRegexp, CML::TagLogic::TokenExp, CML::TagLogic::TokenRegexp

Instance Attribute Summary

Attributes inherited from CML::Tag

#attrs, #cml, #opts, #tag

Attributes included from CML::TagLogic

#errors, #has_grouped_logic, #has_liquid_logic, #logic_tree

Instance Method Summary collapse

Methods inherited from CML::Tag

#cacheable?, #classes, #convert, #ensure_resolved, #gold=, #gold?, #gold_class, #gold_reason, #initialize, #instructions, #iterating?, #label, #legend, memoize, #multi_type, #name, #parent_multiples, #prefix, #preloaded_data, #raw_label, #to_html, #to_liquid, #to_s, #validate?, #validations, #validators, #value, #wrapper, #wrapper_classes

Methods included from CML::TagLogic

#dependencies_on_fields, #dependencies_through_cml_group, #depends_on_fields, #describe_logic_token, #detect_grouped_logic, #detect_liquid_logic, #each_logic_token_in, #expand_logic, #expand_parsed_expression, #in_logic_graph?, #keep_merge!, #only_if, parse_expression, resolve_combinator

Constructor Details

This class inherits a constructor from CML::Tag

Instance Method Details

#childrenObject



26
27
28
29
30
31
32
# File 'lib/cml/tags/radios.rb', line 26

def children
  @cml.xpath(".//cml:radio").map do |c|
    c["name"] ||= name
    c["validates"] ||= @attrs["validates"].to_s
    Radio.new(c, @opts)
  end
end

#contentObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cml/tags/radios.rb', line 13

def content
  cloned= @cml.dup
  c = children
  cloned.xpath(".//cml:*[not(self::cml:radio)]").remove
  cloned.xpath(".//cml:radio").each_with_index do |r,i|
    r.namespace = nil
    r.replace(c[i].convert)
  end
  #Remove the surrounding tag
  cloned.to_xhtml.gsub(/<\/?cml:radios[^>]*?>|<\/?>/,'')
end

#dataObject



9
10
11
# File 'lib/cml/tags/radios.rb', line 9

def data
  super.merge({"content" => content })
end

#finite_value?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cml/tags/radios.rb', line 35

def finite_value?
  true
end