Skip to content

Instantly share code, notes, and snippets.

@danielpchen
danielpchen / sass-explode.scss
Created February 19, 2016 05:18
Sass explode()
// @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));
}
@danielpchen
danielpchen / sass-implode.scss
Last active October 6, 2016 07:07
Sass implode()
// @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)}");