Skip to content

Instantly share code, notes, and snippets.

@jakob-e
Last active August 29, 2015 14:05
Show Gist options
  • Save jakob-e/947d9ffba4d45fe22212 to your computer and use it in GitHub Desktop.
Save jakob-e/947d9ffba4d45fe22212 to your computer and use it in GitHub Desktop.
SCSS paths
// =========================================================
// Paths - SCSS 3.3
// =========================================================
$paths:(
url : '',
img : '../img/',
gfx : '../gfx/',
font : '../fonts/',
);
$path-default:url;
$path-enabled:true;
// Function
$path-default:url !default;
@function url($src, $path:$path-default){
@return unquote(if($path-enabled,('url(' + map-get($paths, $path) + $src +')'),'url('+$src+')'));
}
// Tests
.path_test { content:url('[DEFAULT]');}
.path_test { content:url('[URL]',url);}
.path_test { content:url('[IMAGE]',img);}
.path_test { content:url('[GRAPHIC]',gfx);}
.path_test { content:url('[FONT]',font);}
@import url(styles.css) // should not be affected
// =========================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment