Last active
August 29, 2015 14:13
-
-
Save jakob-e/d75bb6c19aa60cc14965 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com. http://sassmeister.com/gist/d75bb6c19aa60cc14965
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
| SCSS functional-wrapper template |
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.9) | |
| // Compass (v1.0.1) | |
| // ---- | |
| // | |
| // | |
| // 1 Value is passed – attempt to set | |
| // 2 Format input | |
| // 3 Validate input | |
| // 4 Valid => set global | |
| // 5 Invalid => throw error | |
| // 6 Default value (or set outside function) | |
| // 7 Return value | |
| @function functional-wrapper($value: null){ | |
| @if $value != null { // 1 | |
| $value: to-lower-case(#{$value}); // 2 | |
| @if index(valid-value other-valid-value, $value) { // 3 | |
| $__value: $value !global; // 4 | |
| } @else { // 5 | |
| @error "Content direction can be either " | |
| + "`valid-value` or `other-valid-value` (case-insensitive). " | |
| + "Given: `#{$value}`. Aborting."; | |
| } | |
| } | |
| $__value: valid-value !default; // 6 | |
| @return $__value; // 7 | |
| } | |
| .foo { | |
| default: functional-wrapper(); | |
| set-value: functional-wrapper('other-valid-value'); | |
| get-value: functional-wrapper(); | |
| set-value: functional-wrapper('valid-value'); | |
| // error: functional-wrapper(not-so-valid-value); | |
| } |
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
| .foo { | |
| default: valid-value; | |
| set-value: other-valid-value; | |
| get-value: other-valid-value; | |
| set-value: valid-value; | |
| } |
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
| SCSS functional-wrapper template |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment