get-keyword ()
Gets the value of the named parameter from the given argument list, otherwise providing a default value.
Parameters
$args
- The argument list from which to get the named parameter.
- Type
!ArgList
$name
- The name of the parameter to get.
- Type
String
$default
- The value of the parameter when not contained in the argument list.
- Type
*
- Default
null
Return Value
*
- The value of the named parameter when it exists; otherwise, the given default value.
Example
@use 'sass:list';
@use '@sass-fairy/meta';
// 1. Extend `list.zip($list...)` to include `$bracketed` parameter.
@function zip-it($list...) {
$bracketed: meta.get-keyword($list, 'bracketed', auto);
// Keywords must be stripped, otherwise
// they will spread to `list.zip()` where the are not accepted.
$list: meta.strip-keywords($list);
$list: list.zip($list...);
@return list.join($list, (), $bracketed: $bracketed);
}
// 2. Consuming the extended function
@debug zip-it(10px 50px 100px, short mid long, $bracketed: true);
// [10px short, 50px mid, 100px long]