Module: DynamojsRails::Helpers

Defined in:
lib/dynamojs_rails/helpers.rb

Constant Summary collapse

SHORTHANDS =
%w{pause delay speed center delay callback}

Instance Method Summary collapse

Instance Method Details

#dynamo_tag(el, options, config = {}) ⇒ Object

el is the html element type, like :span options are the dynamo options, like w%second



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dynamojs_rails/helpers.rb', line 6

def dynamo_tag el, options, config={}
  config.symbolize_keys
  first = options.shift
  config["data-lines"] = options.join(",")
  c = config[:class]
  if c.blank?
    c = "dynamo"
  else
    c += " dynamo"
  end
  config[:class] = c
  new_config = {}
  config.each do |key, val|
    if SHORTHANDS.include? key.to_s
      new_config["data-#{key}"] = val
    else
      new_config[key] = val
    end
  end
   el, first, new_config
end