Skip to content

Instantly share code, notes, and snippets.

@im-sad
Forked from juanbrujo/sass-maps-index-iterator.css
Created September 12, 2018 09:58
Show Gist options
  • Save im-sad/0b9dcabce84860fe0b0fbdc0f75a9dae to your computer and use it in GitHub Desktop.
Save im-sad/0b9dcabce84860fe0b0fbdc0f75a9dae 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