Class: CML::Tags::Ratings
Constant Summary collapse
- Template =
<<-HTML.freeze {{legend}} <div class="cml_row"> <table> <thead> <tr> <th></th> {% for rating in ratings limit:10 %} <th class="{{gold_classes[forloop.index0]}}">{{rating.raw_label}}</th> {% endfor %} <th></th> </tr> </thead> <tbody> <tr> <td>{{from}}</td> {% for rating in ratings limit:10 %} <td class="{{gold_classes[forloop.index0]}}">{{rating}}</td> {% endfor %} <td>{{to}}</td> </tr> </tbody> </table> </div> 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
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
#children ⇒ Object
43 44 45 |
# File 'lib/cml/tags/ratings.rb', line 43 def children end |
#data ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/cml/tags/ratings.rb', line 30 def data super.merge({ "ratings" => , "from" => @attrs["from"].to_s, "to" => @attrs["to"].to_s, "gold_classes" => gold_classes }) end |
#finite_value? ⇒ Boolean
64 65 66 |
# File 'lib/cml/tags/ratings.rb', line 64 def finite_value? true end |
#gold_classes ⇒ Object
39 40 41 |
# File 'lib/cml/tags/ratings.rb', line 39 def gold_classes .map {|| .gold_class } end |
#ratings ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cml/tags/ratings.rb', line 47 def if @cml.xpath(".//cml:rating").empty? max = @attrs["points"] ? @attrs["points"].to_s.to_i : 4 = Parser.parse((1..max).map do |r| "<cml:rating label='#{r}' />" end.join("\n")).xpath("root/cml:rating") else = @cml.xpath(".//cml:rating") end .map do |c| c["validates"] ||= @attrs["validates"].to_s c["name"] ||= name (@opts[:normalize] ? Checkbox : Radio).new(c, @opts.merge(:bare => true)) end end |