module Middleman::Sass::Functions
def asset_path(_source, _options)
def asset_path(_source, _options) # current_resource end
def current_resource # :nodoc:
Returns a reference to Middleman's current resource.
def current_resource # :nodoc: options[:custom][:current_resource] end
def font_path(source, options={})
src: url(font-path("font.ttf", $digest: true)); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
src: url(font-path("font.ttf")); // src: url("/assets/font.ttf");
=== Examples
arguments that mirror the +options+.
for the given +source+ as a Sass String. This supports keyword
Using Middleman::Util#asset_path, return the full path
def font_path(source, options={}) p = ::Middleman::Util.asset_path(middleman_context, :fonts, source.value, map_options(options)) ::SassC::Script::Value::String.new p.to_s, :string end
def font_url(source, options={})
src: font-url("image.jpg", $digest: true); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
src: font-url("font.ttf"); // src: url("/assets/font.ttf");
=== Examples
arguments that mirror the +options+.
for the given +source+ as a Sass String. This supports keyword
Using Middleman::Util#asset_path, return the url CSS
def font_url(source, options={}) # Work with the Sass #font_url API if options.respond_to? :value case options.value when true return font_path source else options = {} end end ::SassC::Script::Value::String.new "url(#{font_path(source, options)})" end
def image_path(source, options={})
background: url(image-path("image.jpg", $digest: true)); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
background: url(image-path("image.jpg")); // background: url("/assets/image.jpg");
=== Examples
arguments that mirror the +options+.
for the given +source+ as a Sass String. This supports keyword
Using Middleman::Util#asset_path, return the full path
def image_path(source, options={}) p = ::Middleman::Util.asset_path(middleman_context, :images, source.value, map_options(options)) ::SassC::Script::Value::String.new p.to_s, :string end
def image_url(source, options={}, _cache_buster=nil)
background: image-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
background: image-url("image.jpg"); // background: url("/assets/image.jpg");
=== Examples
arguments that mirror the +options+.
for the given +source+ as a Sass String. This supports keyword
Using Middleman::Util#asset_path, return the url CSS
def image_url(source, options={}, _cache_buster=nil) # Work with the Sass #image_url API if options.respond_to? :value case options.value when true return image_path source else options = {} end end ::SassC::Script::Value::String.new "url(#{image_path(source, options)})" end
def map_options(options={}) # :nodoc:
and the values are unwrapped Sass literals.
Returns an options hash where the keys are symbolized
def map_options(options={}) # :nodoc: # ::Sass::Util.map_hash(options) do |key, value| # [key.to_sym, value.respond_to?(:value) ? value.value : value] # end options[:current_resource] = current_resource options end
def middleman_context # :nodoc:
the importer.
Returns a reference to Middleman's context through
def middleman_context # :nodoc: options[:custom][:middleman_context] end