Sha256: 155fe3ab67143689c2d83a846159eec3d0e04ab07546039c6c5e44efe14f750a

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 Bytes

Contents

module Jekyll
  module Assets
    class AssetPath
      attr_writer :anchor, :query

      def initialize(asset)
        asset.bundle!
        @asset = asset
      end

      def cachebust
        @cachebust ||= @asset.site.assets_config.cachebust
      end

      def path
        :hard == cachebust && @asset.digest_path || @asset.logical_path
      end

      def query
        query = []

        query << "cb=#{@asset.digest}" if :soft == cachebust
        query << @query                if @query

        return if query.empty?

        "?" << query.join("&")
      end

      def anchor
        "##{@anchor}" if @anchor
      end

      def to_s
        "#{@asset.site.assets_config.baseurl}/#{path}#{query}#{anchor}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-assets-1.0.0 lib/jekyll/assets/asset_path.rb
jekyll-assets-1.0.0.pre.alpha1 lib/jekyll/assets/asset_path.rb
jekyll-assets-1.0.0.pre.alpha0 lib/jekyll/assets/asset_path.rb