Created
October 13, 2014 16:49
-
-
Save mirisuzanne/6edb61531d1dde365ba8 to your computer and use it in GitHub Desktop.
Map-push function (adds item to list in map)
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
// ---- | |
// Sass (v3.4.5) | |
// Compass (v1.0.1) | |
// ---- | |
// Initial hash | |
$hash: ( | |
hello: world denver pittsburgh, | |
key: value list, | |
); | |
// Push Function | |
@function map-push($map, $key, $value) { | |
@return map-merge($map, ($key: append(map-get($hash, $key), $value))); | |
} | |
// Before | |
.hash-before { | |
@each $key, $value in $hash { | |
#{$key}: $value; | |
} | |
} | |
// Usage | |
$hash: map-push($hash, hello, texas); | |
// After | |
.hash-after { | |
@each $key, $value in $hash { | |
#{$key}: $value; | |
} | |
} |
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
.hash-before { | |
hello: world denver pittsburgh; | |
key: value list; | |
} | |
.hash-after { | |
hello: world denver pittsburgh texas; | |
key: value list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment