Skip to content

Instantly share code, notes, and snippets.

@jakob-e
Last active December 27, 2015 07:39
Show Gist options
  • Save jakob-e/7290310 to your computer and use it in GitHub Desktop.
Save jakob-e/7290310 to your computer and use it in GitHub Desktop.
Simple centralized path control v3.3 (using map)
//=========================================================================
// Paths SCSS 3.3 using map
// - Simple centralized path control
//=========================================================================
// Set default path - if no path is provided
// Enable paths - if false url(...) will work as normal
$paths-default:images !default;
$paths-enabled:true !default;
// Override CSS url(...)
@function url($src, $path:$paths-default){
@if($paths-enabled and map-has-key($paths,$path)){
@return unquote('url('+map-get($paths,$path)+ $src+')');
}
@return unquote('url('+$src+')'); // Disabled, wrong or nulll
}
// Config example
$paths:(
img : '../img/'
,fonts : '../fonts/'
,url : ''
,base64gif : 'data:image/gif;base64,'
,whatever : 'http://www.whatever.com/'
,googlefonts : 'http://fonts.googleapis.com/css?family='
);
$paths-default:img;
$paths-enabled:true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment