Lorraine Bernard
Lorraine Bernard

Reputation: 13430

Escaping string in less and passing variables

By using Less I need to escape a string which LESS doesn’t recognize.

filter: ~"progid:DXImageTransform.Microsoft.gradient(startColorstr=#26ffffff, endColorstr=#24ffffff)";

At the same time I need to pass two variables startColor and endColor to this string

.get-ARGB(@startColor, @endColor){
    /* ARGB backgrounds for IE 7+8 (black background with 50% transparancy) */
    filter: ~"progid:DXImageTransform.Microsoft.gradient(startColorstr=@startColor, endColorstr=@endColor)";
}

Any ideas how can I do it?

Upvotes: 7

Views: 2771

Answers (1)

Tumas
Tumas

Reputation: 1727

Use string interpolation:

   filter: ~"progid:DXImageTransform.Microsoft.gradient(startColorstr=@{startColor}, endColorstr=@{endColor})";

Upvotes: 10

Related Questions