Sha256: 0cb3f5271720ced712a4cb8af98b56a90a5c49cdd181e8c6668301e77de27f2b

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

module Synthesis
  module AssetPackageHelper
    
    def should_merge?
      AssetPackage.merge_environments.include?(RAILS_ENV)
    end

    def javascript_include_merged(*sources)
      options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }

      if sources.include?(:defaults) 
        sources = sources[0..(sources.index(:defaults))] + 
          ['prototype', 'effects', 'dragdrop', 'controls'] + 
          (File.exists?("#{RAILS_ROOT}/public/javascripts/application.js") ? ['application'] : []) + 
          sources[(sources.index(:defaults) + 1)..sources.length]
        sources.delete(:defaults)
      end

      sources.collect!{|s| s.to_s}
      sources = (should_merge? ? 
        AssetPackage.targets_from_sources("javascripts", sources) : 
        AssetPackage.sources_from_targets("javascripts", sources))
        
      sources.collect {|source| javascript_include_tag(source, options) }.join("\n")
    end

    def stylesheet_link_merged(*sources)
      options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }

      sources.collect!{|s| s.to_s}
      sources = (should_merge? ? 
        AssetPackage.targets_from_sources("stylesheets", sources) : 
        AssetPackage.sources_from_targets("stylesheets", sources))

      sources.collect { |source| stylesheet_link_tag(source, options) }.join("\n")    
    end

  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
wontomedia-1.0.7 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-1.0.6 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-1.0.5 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-1.0.4 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-1.0.2 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-1.0.1 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-1.0.0 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-0.2.1 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-0.2.0 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
asset_packager-0.1.0 lib/synthesis/asset_package_helper.rb
wontomedia-0.1.1 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-0.1.0 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-0.0.2 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb
wontomedia-0.0.1 vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb