Module: Sprockets::SassProcessor::Functions
Relationships & Source Files | |
Defined in: | lib/sprockets/sass_processor.rb |
Overview
Public: Functions
injected into Sass context during ::Sprockets
evaluation.
This module may be extended to add global functionality to all ::Sprockets
Sass environments. Though, scoping your functions to just your environment is preferred.
module Functions
def asset_path(path, = {})
end
end
Instance Method Summary
-
#asset_data_url(path)
Public: Generate a data URI for asset path.
-
#asset_path(path, options = {})
Public: Generate a url for asset path.
-
#asset_url(path, options = {})
Public: Generate a asset url() link.
-
#audio_path(path)
Public: Generate url for audio path.
-
#audio_url(path)
Public: Generate a audio url() link.
-
#font_path(path)
Public: Generate url for font path.
-
#font_url(path)
Public: Generate a font url() link.
-
#image_path(path)
Public: Generate url for image path.
-
#image_url(path)
Public: Generate a image url() link.
-
#javascript_path(path)
Public: Generate url for javascript path.
-
#javascript_url(path)
Public: Generate a javascript url() link.
-
#stylesheet_path(path)
Public: Generate url for stylesheet path.
-
#stylesheet_url(path)
Public: Generate a stylesheet url() link.
-
#video_path(path)
Public: Generate url for video path.
-
#video_url(path)
Public: Generate a video url() link.
Instance Method Details
#asset_data_url(path)
Public: Generate a data URI for asset path.
path - Sass::Script::String
logical asset path
Returns a Sass::Script::String
.
#asset_path(path, options = {})
Public: Generate a url for asset path.
Default implementation is deprecated. Currently defaults to Context#asset_path.
Will raise NotImplementedError
in the future. Users should provide their own base implementation.
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 141
def asset_path(path, = {}) path = path.value path, _, query, fragment = URI.split(path)[5..8] path = sprockets_context.asset_path(path, ) query = "?#{query}" if query fragment = "##{fragment}" if fragment Autoload::Sass::Script::String.new("#{path}#{query}#{fragment}", :string) end
#asset_url(path, options = {})
Public: Generate a asset url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 157
def asset_url(path, = {}) Autoload::Sass::Script::String.new("url(#{asset_path(path, ).value})") end
#audio_path(path)
Public: Generate url for audio path.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 202
def audio_path(path) asset_path(path, type: :audio) end
#audio_url(path)
Public: Generate a audio url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 211
def audio_url(path) asset_url(path, type: :audio) end
#font_path(path)
Public: Generate url for font path.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 220
def font_path(path) asset_path(path, type: :font) end
#font_url(path)
Public: Generate a font url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 229
def font_url(path) asset_url(path, type: :font) end
#image_path(path)
Public: Generate url for image path.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 166
def image_path(path) asset_path(path, type: :image) end
#image_url(path)
Public: Generate a image url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 175
def image_url(path) asset_url(path, type: :image) end
#javascript_path(path)
Public: Generate url for javascript path.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 238
def javascript_path(path) asset_path(path, type: :javascript) end
#javascript_url(path)
Public: Generate a javascript url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 247
def javascript_url(path) asset_url(path, type: :javascript) end
#stylesheet_path(path)
Public: Generate url for stylesheet path.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 256
def stylesheet_path(path) asset_path(path, type: :stylesheet) end
#stylesheet_url(path)
Public: Generate a stylesheet url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 265
def stylesheet_url(path) asset_url(path, type: :stylesheet) end
#video_path(path)
Public: Generate url for video path.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 184
def video_path(path) asset_path(path, type: :video) end
#video_url(path)
Public: Generate a video url() link.
path - Sass::Script::String
URL path
Returns a Sass::Script::String
.
# File 'lib/sprockets/sass_processor.rb', line 193
def video_url(path) asset_url(path, type: :video) end