Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Advanced Sass Advanced Directives Using the @each Directive

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,705 Points

Should this work in Sass 3.4.12?

I've been working on this example in Sassmeister where Dale uses @each to iterate through a complex list. Here it is

//list of icon names stored in a variable
$icon-names: (strategy '\e002') (twitter '\e003') (github '\e004');

//use interpolation syntax to loop through the list,
//a variable in singular to loop through the plural variable 

@each $icon-name in $icon-names {
  //pull each value from icon names to be a class selector
 .icon-#{nth($icon-name, 1)}:after {
      content: nth($icon-name, 2);  //works in libsass 3.1.0 and 
                                    //sass 3.3.14 but NOT 3.4.12


I'm just looking for confirmation that this is a technique that doesn't work in the latest version of Sass. This example works in in libsass 3.1.0 and Sass 3.3.14 but NOT **Sass 3.4.12

Edit... Sorry I should explain further that this is the CSS output I get when I try this code in 3.4.12. (including the charset.)

@charset "UTF-8";
.icon-strategy:after {
  content: "";

.icon-twitter:after {
  content: "";

.icon-github:after {
  content: "";

thanks. :)

1 Answer

Chris Shaw
Chris Shaw
26,650 Points

Hi Johnathan,

This appears to be a bug which has already being reported, I would recommend you reply to the issue with your experience.


Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,705 Points

Hi Chris, thanks for letting me know.

Just so long as I know there's nothing wrong with the Syntax. :)