Module: Tipsy::Helpers::AssetTags

Included in:
Tipsy::Helpers
Defined in:
lib/tipsy/helpers/asset_tags.rb

Instance Method Summary collapse

Instance Method Details

#image_tag(src, html_attrs = {}) ⇒ Object



5
6
7
8
9
# File 'lib/tipsy/helpers/asset_tags.rb', line 5

def image_tag(src, html_attrs = {})
  html_attrs.stringify_keys!
  html_attrs.reverse_merge!('alt' => File.basename(src))
  tag(:img, html_attrs.merge('src' => asset_path(src)))
end

#javascript_include_tag(*files) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/tipsy/helpers/asset_tags.rb', line 11

def javascript_include_tag(*files)        
  html_attrs = files.extract_options!
  html_attrs.stringify_keys!
  files.map{ |file| 
    ('script', '', {'src' => asset_path(path_with_ext(file, 'js'))}.merge!(html_attrs))
  }.join("\n")
end


19
20
21
22
23
24
25
26
27
28
# File 'lib/tipsy/helpers/asset_tags.rb', line 19

def stylesheet_link_tag(*files)        
  html_attrs = files.extract_options!
  html_attrs.reverse_merge!({          
    :media => "screen"
  }).stringify_keys!
  
  files.map{ |file| 
    tag('link', { 'href' => asset_path(path_with_ext(file, 'css')), 'rel' => "stylesheet" }.merge!(html_attrs))
  }.join("\n")
end