Skip to content

Instantly share code, notes, and snippets.

@mohsin
Created April 13, 2015 22:25
Show Gist options
  • Save mohsin/a1626b51603dd7a529b7 to your computer and use it in GitHub Desktop.
Save mohsin/a1626b51603dd7a529b7 to your computer and use it in GitHub Desktop.
Sass version of PHP Implode
//
// Returns string after joining list elements with a glue string.
// Similar to PHP's implode function
//
@function implode($list, $glue: '', $is-nested: false)
$result: null
@for $i from 1 through length($list)
$e: nth($list, $i)
@if type-of($e) == list
$result: $result#{to-string($e, $glue, true)}
@else
$result: if($i != length($list) or $is-nested, $result#{$e}#{$glue}, $result#{$e})
@return $result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment