Class: EJX::Template::HTMLTag::AttributeValue
- Inherits:
-
Object
- Object
- EJX::Template::HTMLTag::AttributeValue
- Defined in:
- lib/ejx/template/html_tag/attribute_value.rb
Instance Method Summary collapse
-
#initialize(values) ⇒ AttributeValue
constructor
A new instance of AttributeValue.
- #to_js ⇒ Object
Constructor Details
#initialize(values) ⇒ AttributeValue
Returns a new instance of AttributeValue.
3 4 5 |
# File 'lib/ejx/template/html_tag/attribute_value.rb', line 3 def initialize(values) @values = values end |
Instance Method Details
#to_js ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ejx/template/html_tag/attribute_value.rb', line 7 def to_js if @values.empty? JSON.generate('') else @values.map do |value| if value.is_a?(::String) JSON.generate(value) elsif value.value =~ /\A\s*\w+\s*\z/ value.value else "(" + value.value + ")" end end.join(' + ') end end |