9

I am trying to save a selector in SASS for easier referencing later, however I get a syntax error.

Here's what I'm trying to do:

$icon:  [class*="icon"];

1 Answer 1

11

You need to convert it to a string if you want to use it as a variable:

$icon: '[class*="icon"]';

#{$icon} {
    // stuff
}
5
  • Is there any "shorter" way , so I can write it something like $icon(#{$icon} doesn't really save much writing)?
    – Jon Snow
    Aug 7, 2013 at 11:46
  • Calling unquote() is unnecessary.
    – piouPiouM
    Aug 7, 2013 at 12:18
  • @user2204158 I don't understand what you mean.
    – cimmanon
    Aug 7, 2013 at 14:04
  • @cimmanon i was asking if there's a shorter way to reference the variable, instead of "#{$icon}".
    – Jon Snow
    Aug 7, 2013 at 14:27
  • No, this is your only option. Unless you'd rather use a mixin, but that would be even more verbose.
    – cimmanon
    Aug 7, 2013 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.