Creating or referencing variables dynamically in Sass -
Creating or referencing variables dynamically in Sass -
i'm trying utilize string interpolation on variable reference variable:
class="lang-scss prettyprint-override">// set variable , mixin $foo-baz: 20px; @mixin do-this($bar) { width: $foo-#{$bar}; } // utilize mixin passing 'baz' string param utilize $foo-baz variable in mixin @include do-this('baz'); but when this, next error:
undefined variable: "$foo-".
does sass back upwards php-style variable variables?
sass not allow variables created or accessed dynamically. however, can utilize 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; } http://sass-lang.com/docs/yardoc/file.sass_reference.html#lists http://sass-lang.com/docs/yardoc/sass/script/functions.html#list-functions variables sass
Comments
Post a Comment