Skip to content

Instantly share code, notes, and snippets.

@shadowmint
Created August 27, 2014 00:36
Show Gist options
  • Save shadowmint/f902be990b434646fd49 to your computer and use it in GitHub Desktop.
Save shadowmint/f902be990b434646fd49 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0)
// ----
@function str-split($value) {
$rtn: ();
$tmp: $value;
$busy: true;
@while $busy {
$index: str-index($tmp, ' ');
@if $index {
$bit: str-slice($tmp, 0, $index - 1);
$rtn: append($rtn, $bit);
$tmp: str-slice($tmp, $index + 1);
}
@else {
$rtn: append($rtn, $tmp);
$busy: false;
}
}
@return $rtn;
}
.foo {
@each $key in str-split("This is a long string") {
.#{$key} {
color: #fff;
}
}
}
.foo .This {
color: #fff;
}
.foo .is {
color: #fff;
}
.foo .a {
color: #fff;
}
.foo .long {
color: #fff;
}
.foo .string {
color: #fff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment