iphipps
iphipps

Reputation: 555

Sass mixins to output variable in comments

When working on a big sass library, I like to include flags; big flags for files that import and small flags for the imported files. This makes debugging in the browser easier because I can quickly find the associated sass files and make the change.

Is there a way to have a mixin output comments with an assigned variable? Here's what I've tried.

@mixin bigflag($filepath){
      /***********
        ******  $filepath
       ***********/
    }

@include bigflag(scss/middle/header.scss);

I'd like the above code to output as

      /***********
        ******  scss/middle/header.scss
       ***********/

This did not work; the non closing comment makes the variable inactive, or commented out. I guess I could be copying and pasting the comment flags, but... This would be very convenient.

Any help is appreciated. Thank you

Upvotes: 1

Views: 3737

Answers (1)

iphipps
iphipps

Reputation: 555

After some research on escape characters in sass

@mixin flag($file){
/***********
******  #{$file}
***********/
}
@include flag(scss/middle/header);

outputs as

/***********
******  scss/middle/header
***********/

one note: sass doesn't like periods. so if you use flag(scss/middle/header.scss) you'll need to escape the period before scss. This is painstaking and I'm not going to use it.

Upvotes: 1

Related Questions