dictionary.get()

The dictionary.get() function returns global dictionary(if in use) along with $dictionary and/or from $key.

Global dictionary is in use on $dictionary-global set to true, or by setting $global argument to true.

// Sass.
@use 'sass:list';
@use 'sass:meta';

// Variables.
@forward 'dictionary.variables';
@use 'dictionary.variables' as variables;

// Functions.
@use '../../meta/meta.of-type.function' as *;
@use 'dictionary.is-global.function' as *;

// Modules.
@use '../../map';

// The `translator.dictionary-get()` or `dictionary.get()` function.
@function get($key: null, $dictionary: (), $default: null, $global: null) {
  $dictionary: if(
    meta.type-of($dictionary) == list and list.length($dictionary) > 0,
    map.retrieve(get, $dictionary...),
    $dictionary
  );
  @if is-global($global) {
    @if $key {
      $dictionary: if(
        of-type(
          map,
          map.get(variables.$dictionary, $key, ()),
          map.get($dictionary, $key, $default)
        ),
        map.deep-merge(
          map.get(variables.$dictionary, $key),
          map.get($dictionary, $key, $default)
        ),
        map.get($dictionary, $key, $default) or
          map.get(variables.$dictionary, $key, $default)
      );
    } @else {
      $dictionary: map.deep-merge(variables.$dictionary, $dictionary);
    }
  } @else if $key {
    $dictionary: map.get($dictionary, $key, $default);
  }
  @return $dictionary;
}
https://github.com/angular-package/sass/blob/main/translator/dictionary/_dictionary.get.function.scss

Parameters

$key: null

A key to retrieve dictionary from a global dictionary(if in use) and/or $dictionary.

$dictionary: ()

Dictionary of list(dictionary key) or map type to get along with the global dictionary(if in use).

Dictionary as list indicates getting the dictionary of key, e.g. $dictionary class indicates to get class key of $dictionary.

$default: null

The default returned value if dictionary is null.

$global: null

A bool value indicates whether to use a global dictionary. Default, null, then $dictionary-global is checked.

Return

The return value is a global dictionary(if in use) and/or $dictionary, optionally from $key.

Examples

Last updated

Was this helpful?