1

Here's the code I have:

@color-level-1: #99FFDD;
@color-level-2: #4484F6;
@color-level-3: #E91E63;
@color-level-4: #E99D1E;
@color-level-5: #D51EE9;


.some-color(@i) {
  + .some-class-name {
    background-color: @color-level-@i;
  }
}

.another-class-name {
  .some-color(3);
}

What is trying to accomplish is getting this output when using the mixin:

.another-class-name + .some-class-name {
  background-color: #E91E63;
}

Unfortunately it does not work. What I am getting as an output is:

.another-class-name + .some-class-name {
  background-color:  3;
}

I've tried escaping, but it does not help as well. Does someone have an idea how to make it work?

3rdthemagical
  • 5,271
  • 18
  • 36
MindPhuq
  • 87
  • 1
  • 10

1 Answers1

0

There are two ways to do this. The first one is:

@color-level-1: #99FFDD;
@color-level-2: #4484F6;
@color-level-3: #E91E63;
@color-level-4: #E99D1E;
@color-level-5: #D51EE9;

.some-color(@i) {
  + .some-class-name {
    background-color: ~"@{color-level-@{i}}";
  }
}

.another-class-name {
  .some-color(3);
}

And the second is:

@color-level-1: #99FFDD;
@color-level-2: #4484F6;
@color-level-3: #E91E63;
@color-level-4: #E99D1E;
@color-level-5: #D51EE9;

.some-color(@i) {
  + .some-class-name {
    @color-name: "color-level-@{i}";
    background-color: @@color-name;
  }
}

.another-class-name {
  .some-color(3);
}

Both of these return:

.another-class-name + .some-class-name {
  background-color: #E91E63;
}
MindPhuq
  • 87
  • 1
  • 10