Sha256: c5e5d269ef9d7f097d6ede648b010ed26d759703f31ba3b05618346615b9ff6a
Contents?: true
Size: 976 Bytes
Versions: 1
Compression:
Stored size: 976 Bytes
Contents
module Rails2AssetPipeline module ViewHelpers # Overwrite rails helper to use pipeline path for all relative assets # args: source, 'javascripts', 'js' def compute_public_path(*args) source = args[0] source_is_relative = (source.is_a?(String) and source =~ /^[a-z]+(\/|\.|$)/) # xxx or xxx.js or xxx/yyy, not /xxx or http:// if source_is_relative source = "#{source}.#{args[2]}" unless source.include?(".") super(asset_path(source), *args[1..-1]) else super end end def asset_path(asset) data = Rails2AssetPipeline.env[asset] return "/assets/NOT_FOUND" unless data asset = "/assets/#{asset}" if not Rails2AssetPipeline.dynamic_assets_available or Rails2AssetPipeline::STATIC_ENVIRONMENTS.include?(Rails.env) asset.sub(/(\.[\.a-z]+$)/, "-#{data.digest}\\1") else "#{asset}?#{data.mtime.to_i}" end end module_function :asset_path end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails2_asset_pipeline-0.1.8 | lib/rails2_asset_pipeline/view_helpers.rb |