class Middleman::CoreExtensions::DefaultHelpers

def asset_path(kind, source)

Returns:
  • (String) -

Parameters:
  • source (String) -- The path to the file
  • kind (Symbol) -- The type of file
def asset_path(kind, source)
  return source if source.to_s.include?('//') || source.to_s.start_with?('data:')
  asset_folder = case kind
  when :css
    css_dir
  when :js
    js_dir
  when :images
    images_dir
  when :fonts
    fonts_dir
  else
    kind.to_s
  end
  source = source.to_s.tr(' ', '')
  ignore_extension = (kind == :images || kind == :fonts) # don't append extension
  source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}")
  asset_folder = '' if source.start_with?('/') # absolute path
  asset_url(source, asset_folder)
end