RJP RJP - 4 months ago 11
Sass (Sass) Question

How to have urls with a '$' in a SASS file?

I've inherited legacy code, and theres this portion of a class in css:

background: url(//site.com/path/path/$?wid=3&fmt=png/myimg.jpg)


SASS throws an error because it things the '$' is a variable. How can I get around this if I cannot modify the image path on the server?

Answer

Surround the URL in quotes. Sass does not look for variables within quoted strings, instead you would have to use the interpolation syntax #{}

background: url('//site.com/path/path/$?wid=3&fmt=png/myimg.jpg') 
Comments