Module: SmartAsset::Helper

Defined in:
lib/smart_asset/helper.rb

Instance Method Summary collapse

Instance Method Details

#javascript_include_merged(*javascripts) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/smart_asset/helper.rb', line 4

def javascript_include_merged(*javascripts)
  append = SmartAsset.append_random ? "?#{rand.to_s[2..-1]}" : ''
  output = javascript_paths(*javascripts).collect { |js|
    "<script src=\"#{SmartAsset.prepend_asset_host js}#{append}\"></script>"
  }.join("\n")
  defined?(Rails) && Rails.version[0..0] == '3' ? output.html_safe : output
end

#javascript_paths(*javascripts) ⇒ Object



22
23
24
# File 'lib/smart_asset/helper.rb', line 22

def javascript_paths(*javascripts)
  javascripts.collect { |js| SmartAsset.paths('javascripts', js) }.flatten.uniq
end


12
13
14
15
16
17
18
19
20
# File 'lib/smart_asset/helper.rb', line 12

def stylesheet_link_merged(*stylesheets)
  append = SmartAsset.append_random ? "?#{rand.to_s[2..-1]}" : ''
  options = stylesheets.last.is_a?(::Hash) ? stylesheets.pop : {}
  options[:media] ||= 'screen'
  output = stylesheet_paths(*stylesheets).collect { |css|
    "<link href=\"#{SmartAsset.prepend_asset_host css}#{append}\" media=\"#{options[:media]}\" rel=\"stylesheet\" />"
  }.join("\n")
  defined?(Rails) && Rails.version[0..0] == '3' ? output.html_safe : output
end

#stylesheet_paths(*stylesheets) ⇒ Object



26
27
28
# File 'lib/smart_asset/helper.rb', line 26

def stylesheet_paths(*stylesheets)
  stylesheets.collect { |css| SmartAsset.paths('stylesheets', css) }.flatten.uniq
end