Module: Propshaft::Helper

Defined in:
lib/propshaft/helper.rb

Instance Method Summary collapse

Instance Method Details

#all_stylesheets_pathsObject

Returns a sorted and unique array of logical paths for all stylesheets in the load path.



17
18
19
20
21
22
23
# File 'lib/propshaft/helper.rb', line 17

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

#compute_asset_path(path, options = {}) ⇒ Object



3
4
5
# File 'lib/propshaft/helper.rb', line 3

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.



8
9
10
11
12
13
14
# File 'lib/propshaft/helper.rb', line 8

def stylesheet_link_tag(*sources)
  if sources.first == :all
    super *all_stylesheets_paths
  else
    super
  end
end