Sha256: ea9b92a452d42622814685bcb168dd0ca78fe82bfc58b3d6ebc0e7e7678ad627

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

module RailsAssetPackager
  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))

      raw(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))

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_asset_packager-0.2.2 lib/rails_asset_packager/asset_package_helper.rb
rails_asset_packager-0.2.1 lib/rails_asset_packager/asset_package_helper.rb
rails_asset_packager-0.2.0 lib/rails_asset_packager/asset_package_helper.rb
rails_asset_packager-0.1.3 lib/rails_asset_packager/asset_package_helper.rb