-
-
Save rubiadias/62c6b07d603f9ad4787f84a95c1a9229 to your computer and use it in GitHub Desktop.
Sass str-to-list function converts a string to a list
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
$selectorItems: str-to-list(#{&}); | |
@each $selectorItem in $selectorItems { | |
@debug $selectorItem; | |
} |
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 str-to-list($string, $separator: ' ', $startAt: 1) { | |
$workStr: str-slice($string,$startAt); | |
$list: (); | |
$indexOfFirstSpace: str-index($workStr,$separator); | |
@if $indexOfFirstSpace == null { | |
$list: ($workStr); | |
} @else { | |
$list: (str-slice($workStr, 1, $indexOfFirstSpace - 1)); | |
$list: join($list,str-to-list($workStr, $startAt: $indexOfFirstSpace + 1)); | |
} | |
@return $list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment