Sha256: 93c4bc6c24c7bf5dce9b5f9ee25ae44fff8e18a16a790ec4a3484018be8a1970
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
module Sprockets module Helpers # `AssetPath` generates a full path for an asset # that exists in Sprockets environment. class AssetPath < BasePath def initialize(uri, asset, environment, options = {}) @uri = uri @asset = asset @environment = environment @options = { :body => false, :digest => Helpers.digest, :prefix => Helpers.prefix }.merge options @uri.path = @options[:digest] ? asset.digest_path : asset.logical_path end def to_a if @asset.respond_to?(:to_a) @asset.to_a.map do |dependency| AssetPath.new(@uri.clone, dependency, @environment, @options.merge(:body => true)).to_s end elsif @asset.metadata[:included] @asset.metadata[:included].map do |uri| AssetPath.new(@uri.clone, @environment.load(uri), @environment, @options.merge(:body => true)).to_s end else AssetPath.new(@uri.clone, @asset, @environment, @options.merge(:body => true)).to_s end end protected def rewrite_path prefix = if options[:prefix].respond_to? :call warn 'DEPRECATION WARNING: Using a Proc for Sprockets::Helpers.prefix is deprecated and will be removed in 1.0. Please use Sprockets::Helpers.asset_host instead.' options[:prefix].call uri.path else options[:prefix].to_s end prepend_path(prefix) end def rewrite_query append_query('body=1') if options[:body] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sprockets-helpers-1.3.0 | lib/sprockets/helpers/asset_path.rb |