treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Sass Function Return a Comment?

  • Anyone know if it is possible to return a comment in a function and have it compile it into the CSS?

    @function em($target, $context: $base-font-size)
      @if $target == 0
        @return 0
      @return $target / $context + 0em /* #{$target} / #{$context} */
    

    Used like this

    $base-font-size: 16px 
    selector
      font-size: em(20px)
    

    Ideally that would compile to this

    .selector {
      font-size: 1.25em; /*  20px / 16px  */
    }
    

    I use compass and have tried /*! comment here */ but that only seems to work at the top of the document. This is just like a nice to have. Once a project leaves my desk the CSS is typically used and my sass is tossed. Crazy to me but whatever.