Created
July 29, 2014 23:24
-
-
Save benib/92b22ef0716d571d796a to your computer and use it in GitHub Desktop.
Sass str-to-list function converts a string to a list
This file contains 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 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
you've forgot the separator in the str-to-list when you call it at #9.