module Middleman::CoreExtensions::DefaultHelpers::Helpers
def asset_path(kind, source)
-
(String)
-
Parameters:
-
source
(String
) -- The path to the file -
kind
(Symbol
) -- The type of file
def asset_path(kind, source) return source if source =~ /^http/ asset_folder = case kind when :css then css_dir when :js then js_dir when :images then images_dir else kind.to_s end source = source.to_s.gsub(/\s/, '') ignore_extension = (kind == :images) # don't append extension source << ".#{kind}" unless ignore_extension or source =~ /\.#{kind}/ result_path = source if source =~ %r{^/} # absolute path result_path ||= asset_url(source, asset_folder) "#{result_path}" end