omega
omega

Reputation: 43953

How to get variable in string in SASS?

In SASS, I have this

background-image:url('/folder/pic.png');

but I want to do something like this

$scope : "folder";
background-image:url('/[$scope]/pic.png');

how can I do this in SASS?

Thanks

Upvotes: 1

Views: 99

Answers (3)

krishna raikar
krishna raikar

Reputation: 2675

background-image:url('/' + $scope + '/pic.png');

or

background-image:url('/#{$scope}/pic.png');

Upvotes: 1

FluffyKitten
FluffyKitten

Reputation: 14312

You should be able to do it like this:

background-image:url(/#{$scope}/pic.png);

Upvotes: 2

Jon Uleis
Jon Uleis

Reputation: 18659

You're very close - you can use #{$var} to include variables in strings and other tricky places.

The syntax would be this:

$scope: "folder";
background-image: url('/#{$scope}/pic.png');

Upvotes: 2

Related Questions