dictionary.merge()
The dictionary.merge() function returns global dictionary(if in use) merged with multiple dictionaries from $dictionary optionally merged in $key.
// Sass.
@use 'sass:list';
@use 'sass:meta';
// Variables.
@forward 'dictionary.variables';
@use 'dictionary.variables' as variables;
// Functions.
@use 'dictionary.get.function' as *;
@use 'dictionary.is-global.function' as *;
// Modules.
@use '../../map';
// The `translator.dictionary-merge()` or `dictionary.merge()` function.
@function merge($key: null, $dictionary, $global: null) {
@if type-of($dictionary) == list {
$retrieved-dictionary: ();
@each $dictionary in if(list.separator($dictionary) == comma, $dictionary, ($dictionary,)) {
@if type-of($dictionary) == list and list.length($dictionary) > 1 {
$dictionary: map.retrieve(pick, list.nth($dictionary, 1), list.nth($dictionary, 2));
}
$retrieved-dictionary: map.deep-merge($retrieved-dictionary, $dictionary);
}
$dictionary: $retrieved-dictionary;
}
$dictionary: if(
$key,
map.merge(get($global: $global), list.append($key, $dictionary)...),
map.deep-merge(get($global: $global), $dictionary)
);
@if is-global($global) {
variables.$dictionary: $dictionary;
}
@return $dictionary;
}https://github.com/angular-package/sass/blob/main/translator/dictionary/_dictionary.merge.function.scss
Parameters
$key: null
$key: nullThe optional key under which multiple dictionaries from $dictionary are being merged.
$dictionary: ()
$dictionary: ()Dictionary or multiple dictionaries of map or list type(dictionary keys, dictionary keys) to merge with a global dictionary(if in use) optionally in $key.
$global: null
$global: nullA bool value indicates whether to use a global dictionary. Default, null, then $dictionary-global is checked.
Return
The return value is a dictionary consists of global dictionary(if in use) and multiple dictionaries from $dictionary optionally merged in $key.
Examples
Merge in $key
$keyMerge in nested $key
$keyMultiple dictionaries
Last updated
Was this helpful?