Sha256: ee7c6de89ed97cf09771e1073dbe45f6f3c376112ed0fa8fb907743d328c586e

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

module Propshaft
  module Helper
    def compute_asset_path(path, options = {})
      Rails.application.assets.resolver.resolve(path) || raise(MissingAssetError.new(path))
    end

    # Add an option to call `stylesheet_link_tag` with `:all` to include every css file found on the load path.
    def stylesheet_link_tag(*sources)
      if sources.first == :all
        super *all_stylesheets_paths
      else
        super
      end
    end

    # Returns a sorted and unique array of logical paths for all stylesheets in the load path.
    def all_stylesheets_paths
      Rails.application.assets.load_path
        .assets(content_types: [ Mime::EXTENSION_LOOKUP["css"] ])
        .collect { |css| css.logical_path.to_s }
        .sort
        .uniq
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propshaft-0.8.0 lib/propshaft/helper.rb