Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Created August 4, 2015 13:49
Show Gist options
  • Save juanbrujo/a127cf7b76df63ea16dc to your computer and use it in GitHub Desktop.
Save juanbrujo/a127cf7b76df63ea16dc to your computer and use it in GitHub Desktop.
sass-maps loop with index iterator
/**
* output from sass-maps-index-iterator.scss
*/
li:nth-of-type(1):before {
content: "english - hello";
}
li:nth-of-type(2):before {
content: "spanish - hola";
}
li:nth-of-type(3):before {
content: "deutsch - hallo";
}
li:nth-of-type(4):before {
content: "french - bonjour";
}
li:nth-of-type(5):before {
content: "gaelic - dia duit";
}
li:nth-of-type(6):before {
content: "icelandic - hae";
}
li:nth-of-type(7):before {
content: "italian - ciao";
}
$list: (
"english": "hello",
"spanish": "hola",
"deutsch": "hallo",
"french": "bonjour",
"gaelic": "dia duit",
"icelandic": "hae",
"italian": "ciao"
);
$list-length: length($list);
@for $i from 1 through $list-length {
$iterator: nth($list, $i);
$key: nth($iterator, 1);
$value: nth($iterator, 2);
li:nth-of-type(#{$i}):before {
content: $key + " - " + $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment