0

I would like to have the following structure:

sass: rule //coment

But comments with // seems to be accepted only on new lines.

Is there a way to comment a sass rule in the same line the rule is?

fotanus
  • 19,618
  • 13
  • 77
  • 111
  • 1
    Possible Duplicate: http://stackoverflow.com/questions/13355989/does-sass-support-inline-comments –  Mar 17 '13 at 17:32
  • True, thanks for point this out. Couldn't find searching stackoverflow – fotanus Mar 17 '13 at 22:44
  • No problem, i just usually do a google site-specific search for every question b4 i answer it. –  Mar 17 '13 at 23:07

2 Answers2

2

The alternative way of writing comments is like this:

/* comment text here */

Be aware that this type of comment will be preserved in your generated css though, unless you use the compressed option.

Matt Cain
  • 5,638
  • 3
  • 36
  • 45
  • Thanks! It seems that my vim lacks highlight for this comment. – fotanus Mar 17 '13 at 22:44
  • Documentation backs you up on this but, somehow, I've managed to inherit some .sass file that have these comments . Crazy thing is, sometimes the compiler chokes and sometimes it doesn't! Any insight by any chance? – Montagist Apr 02 '14 at 20:28
  • @Montagist Sorry, I would just be aimlessly guessing if I tried to suggest anything, you should submit a question of your own with an example or two. – Matt Cain Apr 03 '14 at 14:36
1

Yes you can. But only on new lines, or after a property:value pair. Perhaps an obscure bug, but they can break on compile if added after a selector. This May be fixed in a more recent version of SASS, so if you're having compile problems with comments, check the positioning as stated below (or update your version).

i.e.

// This works
.myclass
    width: 30px //comment

// This breaks for some on compile
.myclass //comment
    width: 30px

// This style is sass only and won't be compiled/output in the final css file
/* this style will be seen in final css file as a normal css comment */
Skäggiga Mannen
  • 984
  • 7
  • 16
  • Thanks, but actually right now nothing breaks compiling any longer. Test yourself. I have answered my own question. – fotanus Jul 15 '14 at 22:57
  • Ok great! Maybe it's a recent update (answer updated). We were testing this yesterday, and noticed that it compiles fine for some people in our office, and breaks for others (but only if there is a comment after a selector). It's very odd behavior. – Skäggiga Mannen Jul 16 '14 at 13:00