Module: Middleman::Sass::Functions
- Defined in:
- lib/middleman-core/renderers/sass_functions.rb
Instance Method Summary collapse
- #asset_path(_source, _options) ⇒ Object
-
#font_path(source, options = {}) ⇒ Object
Using Middleman::Util#asset_path, return the full path for the given +source+ as a Sass String.
-
#font_url(source, options = {}) ⇒ Object
Using Middleman::Util#asset_path, return the url CSS for the given +source+ as a Sass String.
-
#image_path(source, options = {}) ⇒ Object
Using Middleman::Util#asset_path, return the full path for the given +source+ as a Sass String.
-
#image_url(source, options = {}, _cache_buster = nil) ⇒ Object
Using Middleman::Util#asset_path, return the url CSS for the given +source+ as a Sass String.
Instance Method Details
#asset_path(_source, _options) ⇒ Object
4 5 6 |
# File 'lib/middleman-core/renderers/sass_functions.rb', line 4 def asset_path(_source, ) # current_resource end |
#font_path(source, options = {}) ⇒ Object
Using Middleman::Util#asset_path, return the full path for the given +source+ as a Sass String. This supports keyword arguments that mirror the +options+.
=== Examples
src: url(font-path("font.ttf")); // src: url("/assets/font.ttf"); src: url(font-path("font.ttf", $digest: true)); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
54 55 56 57 |
# File 'lib/middleman-core/renderers/sass_functions.rb', line 54 def font_path(source, ={}) p = ::Middleman::Util.asset_path(middleman_context, :fonts, source.value, ()) ::SassC::Script::Value::String.new p.to_s, :string end |
#font_url(source, options = {}) ⇒ Object
Using Middleman::Util#asset_path, return the url CSS for the given +source+ as a Sass String. This supports keyword arguments that mirror the +options+.
=== Examples
src: font-url("font.ttf"); // src: url("/assets/font.ttf"); src: font-url("image.jpg", $digest: true); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/middleman-core/renderers/sass_functions.rb', line 68 def font_url(source, ={}) # Work with the Compass #font_url API if .respond_to? :value case .value when true return font_path source else = {} end end ::SassC::Script::Value::String.new "url(#{font_path(source, )})" end |
#image_path(source, options = {}) ⇒ Object
Using Middleman::Util#asset_path, return the full path for the given +source+ as a Sass String. This supports keyword arguments that mirror the +options+.
=== Examples
background: url(image-path("image.jpg")); // background: url("/assets/image.jpg"); background: url(image-path("image.jpg", $digest: true)); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
17 18 19 20 |
# File 'lib/middleman-core/renderers/sass_functions.rb', line 17 def image_path(source, ={}) p = ::Middleman::Util.asset_path(middleman_context, :images, source.value, ()) ::SassC::Script::Value::String.new p.to_s, :string end |
#image_url(source, options = {}, _cache_buster = nil) ⇒ Object
Using Middleman::Util#asset_path, return the url CSS for the given +source+ as a Sass String. This supports keyword arguments that mirror the +options+.
=== Examples
background: image-url("image.jpg"); // background: url("/assets/image.jpg"); background: image-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/middleman-core/renderers/sass_functions.rb', line 31 def image_url(source, ={}, _cache_buster=nil) # Work with the Compass #image_url API if .respond_to? :value case .value when true return image_path source else = {} end end ::SassC::Script::Value::String.new "url(#{image_path(source, )})" end |