List
Because the sass:list
module already, the namespace is prefixed with an
underscore to avoid conflict.
@use "@glsass/tools/tools.list" as _list;
first()
Retrieves the first element of a list.
_list.first($list);
_list.first(("one", "two", "three"));
// Returns "one"
last()
Retrieves the last element of a list.
_list.last($list);
_list.last(("one", "two", "three"));
// Returns "three"
prepend()
Add news values at beginning of the list (opposite logic of list.append
).
prepend($list);
prepend(("one", "two", "three"), "zero");
// Returns ("zero", "one", "two", "three")
to-string()
Convert a list into the string, with the ability to use a string to join elements with each others.
to-string($list, $glue: "", $is-nested: false);
to-string(("a", "b", "c"));
// Returns "abc"
to-string(("block", "element", "modifier"), "-");
// Returns "block-element-modifier"
is-empty()
Indicates if the list is empty.
is-empty($list);
is-empty(("one", "two", "three"));
// Returns false
is-empty(());
// Returns true