Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Advanced Sass Advanced Directives Using the @each Directive

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 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,676 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.

https://github.com/sass/sass/issues/1663

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi Chris, thanks for letting me know.

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