Last active
August 29, 2015 14:05
-
-
Save jakob-e/947d9ffba4d45fe22212 to your computer and use it in GitHub Desktop.
SCSS paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================= | |
// 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