Skip to content

Instantly share code, notes, and snippets.

@jakob-e
Last active August 29, 2015 14:13
Show Gist options
  • Save jakob-e/d75bb6c19aa60cc14965 to your computer and use it in GitHub Desktop.
Save jakob-e/d75bb6c19aa60cc14965 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com. http://sassmeister.com/gist/d75bb6c19aa60cc14965
SCSS functional-wrapper template
// ----
// 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);
}
.foo {
default: valid-value;
set-value: other-valid-value;
get-value: other-valid-value;
set-value: valid-value;
}
SCSS functional-wrapper template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment