Module: EffectiveRte::Utils
- Defined in:
- lib/effective_rte/utils.rb
Class Method Summary collapse
Class Method Details
.js_replace(dom_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/effective_rte/utils.rb', line 5 def js_replace(dom_id, = {}) = () if .blank? js = "$('##{dom_id}').wymeditor();" else js = "$('##{dom_id}').wymeditor({#{js_options}});" end end |
.jsify_options(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/effective_rte/utils.rb', line 15 def () str = [] .each do |key, value| item = case value when String then value.split(//).first == '^' ? value.slice(1..-1) : "'#{value}'" when Hash then "{ #{jsify_options(value)} }" when Array then arr = value.collect { |v| "'#{v}'" } "[ #{arr.join(',')} ]" else value end str << %Q{"#{key}": #{item}} end str.sort.join(',') end |