Sha256: c6bda2fc1d4638811f6aea2d63c00efbbeeead1872a9a415eac440738d86f3bd

Contents?: true

Size: 1.18 KB

Versions: 22

Compression:

Stored size: 1.18 KB

Contents

class SmartAsset
  module Helper
    
    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
    
    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
    
    def javascript_paths(*javascripts)
      javascripts.collect { |js| SmartAsset.paths('javascripts', js) }.flatten.uniq
    end
    
    def stylesheet_paths(*stylesheets)
      stylesheets.collect { |css| SmartAsset.paths('stylesheets', css) }.flatten.uniq
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
smart_asset-0.6.0 lib/smart_asset/helper.rb
smart_asset-0.5.11 lib/smart_asset/helper.rb
smart_asset-0.5.10 lib/smart_asset/helper.rb
smart_asset-0.5.9 lib/smart_asset/helper.rb
smart_asset-0.5.8 lib/smart_asset/helper.rb
smart_asset-0.5.7 lib/smart_asset/helper.rb
smart_asset-0.5.6 lib/smart_asset/helper.rb
smart_asset-0.5.5 lib/smart_asset/helper.rb
smart_asset-0.5.4 lib/smart_asset/helper.rb
smart_asset-0.5.3 lib/smart_asset/helper.rb
smart_asset-0.5.2 lib/smart_asset/helper.rb
smart_asset-0.5.1 lib/smart_asset/helper.rb
smart_asset-0.5.0 lib/smart_asset/helper.rb
smart_asset-0.4.7 lib/smart_asset/helper.rb
smart_asset-0.4.6 lib/smart_asset/helper.rb
smart_asset-0.4.5 lib/smart_asset/helper.rb
smart_asset-0.4.4 lib/smart_asset/helper.rb
smart_asset-0.4.3 lib/smart_asset/helper.rb
smart_asset-0.4.2 lib/smart_asset/helper.rb
smart_asset-0.4.1 lib/smart_asset/helper.rb