Created
September 8, 2014 17:14
-
-
Save tjbenton/62c15099a1e8949be385 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.4.3) | |
// Compass (v1.0.1) | |
// ---- | |
// @author Tyler Benton | |
// @page helpers/functions | |
// @description Splits string at the specified point | |
// | |
// @arg {string} | |
// @arg {string} | |
// @arg {list} - This is a temp list to make this function recursive and shouldn't be used. | |
// | |
// @returns {list} | |
@function str-split($str, $key: " ", $temp: ()){ | |
$index: str-index($str, $key); | |
@return if($index != null, | |
str-split(str-slice($str, $index + 1), $key, append($temp, str-slice($str, 0, $index - 1), "comma")), | |
append($temp, $str) | |
); | |
} | |
// test | |
.str-split{ | |
$string: "Lorem ipsum dolor sit amet, consectetur adipisicing elit."; | |
original: $string; | |
split-at-space: str-split($string); | |
split-at-comma: str-split($string, ","); | |
} |
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
.str-split { | |
original: "Lorem ipsum dolor sit amet, consectetur adipisicing elit."; | |
split-at-space: "Lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipisicing", "elit."; | |
split-at-comma: "Lorem ipsum dolor sit amet", " consectetur adipisicing elit."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment