Created
March 16, 2015 21:14
-
-
Save micahgodbolt/bc0f7b8ad402225e4bb1 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or 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
// ---- | |
// Sass (v3.4.12) | |
// Compass (v1.0.3) | |
// ---- | |
//$namespace: null !default; | |
//$#{$namespace}variable: value; | |
// Want output like: | |
// $namespaced-variable: value; | |
// Reasoning: | |
// I'm building a scss/css framework | |
// and started realizing that variable | |
// names like $base-font-size might | |
// cause conflicts for people. | |
// I could just namespace all of my | |
// variables, but I personally hate | |
// namespacing in my own stuff so I | |
// want it to be optional. Would like | |
// a $namespace variable that is set | |
// to null !default | |
// If someone wants a namespace on | |
// all the variables, they just change | |
// that variable to a real value and | |
// everything has a namespace now. | |
// You can see a similar approach to | |
// namespacing selectors here: | |
// https://github.com/ScalesCSS/base-forms/blob/master/_forms.scss | |
// line 12 and line 41 | |
// If I can do this with maps, I'm | |
// missing how. | |
$my-framework-vars: ( | |
base-font-size: 16px, | |
base-font-color: #333, | |
); | |
@function get-var($var) { | |
@return map-get($my-framework-vars, $var) | |
} | |
body { | |
font-size: get-var(base-font-size); | |
color: get-var(base-font-color); | |
} |
This file contains hidden or 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
body { | |
font-size: 16px; | |
color: #333; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment