Module: Middleman::Sprockets::Extension::ContextMethods
- Defined in:
- lib/middleman-sprockets/extension/context_methods.rb
Instance Method Summary collapse
Instance Method Details
#asset_path(path, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/middleman-sprockets/extension/context_methods.rb', line 13 def asset_path path, ={} # Handle people calling with the Middleman/Padrino asset path signature if path.is_a?(::Symbol) && !.is_a?(::Hash) kind = path path = else kind = { image: :images, font: :fonts, javascript: :js, stylesheet: :css }.fetch([:type], [:type]) end if File.extname(path).empty? path << { js: '.js', css: '.css' }.fetch(kind, '') end if app.extensions[:sprockets].check_asset(path) link_asset(path) File.join *[app.config[:http_prefix], app.extensions[:sprockets].sprockets_asset_path(env[path])].compact else app.asset_path(kind, path) end end |
#current_path ⇒ Object
9 10 11 |
# File 'lib/middleman-sprockets/extension/context_methods.rb', line 9 def current_path current_resource.destination_path if current_resource end |
#current_resource ⇒ Object
5 6 7 |
# File 'lib/middleman-sprockets/extension/context_methods.rb', line 5 def current_resource app.extensions[:sprockets].resources.find_by_path(filename) end |