Creating or referencing variables dynamically in Sass -
i'm trying use string interpolation on variable reference variable:
// set variable , mixin $foo-baz: 20px; @mixin do-this($bar) { width: $foo-#{$bar}; } // use mixin passing 'baz' string param use $foo-baz variable in mixin @include do-this('baz'); but when this, following error:
undefined variable: "$foo-".
does sass support php-style variable variables?
sass not allow variables created or accessed dynamically. however, can use lists similar behavior.
scss:
$medium: 2; $width: 20px 30px 40px; @mixin do-this($bar) { width: nth($width, $bar); } #smth { @include do-this($medium); } css:
#smth { width: 30px; }
Comments
Post a Comment