Skip to content

Instantly share code, notes, and snippets.

@mirisuzanne
Created August 19, 2014 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirisuzanne/1bde777fb07b78e34792 to your computer and use it in GitHub Desktop.
Save mirisuzanne/1bde777fb07b78e34792 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
$map: (
hello: world,
goodbye: pittsburgh,
);
@function replace-pair(
$map,
$needle,
$pair
) {
$new: ();
@each $key, $value in $map {
@if $key == $needle {
$new: map-merge($new, $pair);
} @else {
$new: map-merge($new, ($key: $value));
}
}
@return $new;
}
@mixin output-map($map) {
@each $key, $value in $map {
#{$key}: $value;
}
}
$test: replace-pair($map, goodbye, (new: pair));
.test {
@include output-map($test);
}
.test {
hello: world;
new: pair;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment