Module: YMDP::AssetTagHelper

Included in:
Compiler::Template::View
Defined in:
lib/ymdp/view/asset_tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#image_tag(source, options = {}) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/ymdp/view/asset_tag_helper.rb', line 63

def image_tag(source, options = {})
  # options.symbolize_keys!

  options[:src] = path_to_image(source)
  options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize

  if size = options.delete(:size)
    options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
  end

  if mouseover = options.delete(:mouseover)
    options[:onmouseover] = "this.src='#{path_to_image(mouseover)}'"
    options[:onmouseout]  = "this.src='#{path_to_image(options[:src])}'"
  end

  tag("img", options)
end