Module: SmartAsset::Helper
- Defined in:
- lib/smart_asset/helper.rb
Instance Method Summary collapse
- #javascript_include_merged(*javascripts) ⇒ Object
- #javascript_paths(*javascripts) ⇒ Object
- #stylesheet_link_merged(*stylesheets) ⇒ Object
- #stylesheet_paths(*stylesheets) ⇒ Object
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 |
#stylesheet_link_merged(*stylesheets) ⇒ Object
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]}" : '' = stylesheets.last.is_a?(::Hash) ? stylesheets.pop : {} [:media] ||= 'screen' output = stylesheet_paths(*stylesheets).collect { |css| "<link href=\"#{SmartAsset.prepend_asset_host css}#{append}\" media=\"#{[: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 |