Skip to content

Instantly share code, notes, and snippets.

@jakob-e
Last active December 27, 2015 07:29
Show Gist options
  • Save jakob-e/7289166 to your computer and use it in GitHub Desktop.
Save jakob-e/7289166 to your computer and use it in GitHub Desktop.
Simple centralized path control v3.12
//=========================================================================
// Paths
// - 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){
@for $p from 1 through length($paths){
@if(nth(nth($paths,$p),1)==$path){
@return unquote('url('+nth(nth($paths,$p),2)+$src+')');
}
}
}
@return unquote('url('+$src+')'); // Disabled, wrong or nulll
}
// Config example
$paths:(
(images,'../img/')
,(fonts ,'../fonts/')
,(url, '')
,(base64gif, 'data:image/gif;base64,')
,(whatever, 'http://www.whatever.com/')
,(googlefonts,'http://fonts.googleapis.com/css?family=')
);
$paths-default:images;
$paths-enabled:true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment