Created
July 1, 2015 15:41
-
-
Save jdsteinbach/4b599e49e090d515669c 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
| <p class="output"> | |
| The output number is | |
| </p> |
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
| // ---- | |
| // libsass (v3.2.5) | |
| // ---- | |
| /** | |
| * | |
| * Is there any way to fetch the last key and a specific key inside it? | |
| * | |
| **/ | |
| $map: ( | |
| key-1: ( | |
| first: true, | |
| number: 1, | |
| ), | |
| key-2: ( | |
| first: false, | |
| number: 2, | |
| ), | |
| ); | |
| // Map last key function by James Steinbach | |
| @function map-last-key($map) { | |
| $keys: map-keys($map); | |
| @return nth($keys, length($keys)); | |
| } | |
| // Get a specific value from the last nested map by James Steinbach | |
| @function map-last-value($map, $sub-key) { | |
| $last-value: map-get($map, map-last-key($map)); | |
| @return map-get($last-value, $sub-key); | |
| } | |
| // Map fetch function by Hugo Giraudel | |
| @function map-fetch($map, $keys) { | |
| @each $key in $keys { | |
| $map: map-get($map, $key); | |
| } | |
| @return $map; | |
| } | |
| .output:after { | |
| last-key: map-last-key($map); | |
| last-value: map-last-value($map, number); | |
| content: '' + map-fetch($map, key-2 number); | |
| } |
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
| /** | |
| * | |
| * Is there any way to fetch the last key and a specific key inside it? | |
| * | |
| **/ | |
| .output:after { | |
| last-key: key-2; | |
| last-value: 2; | |
| content: "2"; | |
| } |
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
| <p class="output"> | |
| The output number is | |
| </p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment