question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dynamic variables

See original GitHub issue

I am hoping someone with more sass knowledge can let me know if creating variables from a sass map is at all possible. here is a contrived example of what i am trying to do…

$colors-map: (
  "red": (
    dark: #aa142d
  ),
);

@each $name, $variations in $colors-map {
  @each $variation, $hex in $variations {
    $color-#{$name}-#{$variation}: $hex;
  }
}

.foo {
  background-color: $color-red-dark;
}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
lolmauscommented, Sep 26, 2014

Duplicate.

PS Use maps.

22reactions
lolmauscommented, Sep 27, 2014

im just storing hex values in a variable so i wouldn’t say its legacy, i just want a drop-in solution using maps that is easier to maintain.

Replace

$color-red: #a00;
html { foo: $color-red; }

with

$colors: ('red': #a00);
html { foo: map-get($colors, 'red'); }

or even better with:

@function col($col) {
  @return map-get($colors, '#{$col}');
}

$colors: ('red': #a00);
html { foo: col(red); }

is there any plans on supporting variable interpolation in the future?

This question has been asked many times since 2011. You’ve been linked to the issue where this question is answered.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic variables | Postman Learning Center
Dynamic variables. Postman uses the faker library to generate sample data, including random names, addresses, email addresses, and much more.
Read more >
Dynamic Variables Overview | Junos OS - Juniper Networks
Dynamic variables are data placeholders that you define and place in dynamic profiles. When a particular event occurs on an interface (for example, ......
Read more >
Introduction to Dynamic Variables and Fields
Dynamic variables are defined without any length. Memory will be allocated either implicitly at execution time, when the dynamic variable is used as...
Read more >
What Is a Dynamic Variable? - EasyTechJunkie
A dynamic variable is a public modifier in object oriented programming that indicates that the execution of information at run...
Read more >
Dynamic variables - Postman Quick Reference Guide
Variable name Description Examples $randomCity City East Ryanfurt, Jenkinsview $randomStreetName Street name Mckenna Pines, Schiller Highway, Vandervort P... $randomStreetAddress Street with number 98165 Tanya Passage, 0695...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found