Commenting - Chapter 7

  • 0
Although sounds silly, there are people who takes these things seriously! Especially when your code is under a review. The first remark would be, "Remove unnecessary comments and make the style-sheets more concise"

No worries, we can have our SCSS commented heavily, but along with that , make sure that it doesnt get flown to the output css. In that way, we can have lots of info included for other developers which will come in quite handly in a huge projects, especially, if a particular developer has marked a fix for an issue and he has commented the  same clearly.
.btn {     
  font-family: Arial;
  color: #ffffff;
  font-size: 28px;
  padding: 10px 30px 10px 30px;
  text-decoration: none; 
  background-color: red;  
  
  /*This comment will be outputted in the css */
  body#green &{
    background-color: green;  
  }
  
  //This comment wont be outputted. 
  //This is internal to sass and so will be ignored while compiling
    
  body#blue &{
    background-color: blue;  
  }  
}
Any comments made inside the /* */ will be present in the output.
Any comments made using the // will get ignored in the css compiling.
Try giving both and see which one comes and which one doesnt if you would like to check them out in the final css stylesheet.






No comments:

Post a Comment