This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @function explode() -- split a string into a list of strings | |
// {string} $string: the string to be split | |
// {string} $delimiter: the boundary string | |
// @return {list} the result list | |
@function explode($string, $delimiter) { | |
$result: (); | |
@if $delimiter == "" { | |
@for $i from 1 through str-length($string) { | |
$result: append($result, str-slice($string, $i, $i)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @function implode() -- join list elements to form a single string | |
// {string} $pieces: the list of strings to implode | |
// {string} $glue: the "glue" between elements in the result string | |
// @return {string} the result string | |
@function implode($pieces, $glue: "") { | |
$result: null; | |
@for $i from 1 through length($pieces) { | |
$piece: nth($pieces, $i); | |
@if type-of($piece) == list { | |
$result: unquote("#{$result}#{$glue}#{implode($piece, $glue)}"); |