P
P
Pavel2422015-07-26 21:32:11
css
Pavel242, 2015-07-26 21:32:11

Is it possible in LESS to call a mixin whose name is in a variable?

Is it possible to "execute" a mixin through a variable?
I would like something like this

.mixin {
/* ... */
}

@name: mixin;

.classname {
/* как-то так [email protected]{name}  - не работает*/
}

Let me correct the issue a bit. I have a mixin where I pass two class names. In addition to some operations with them, I also wanted to call one in the context of the other, i.e. operation of the form
.class1 {
   .class2;
}

In general, do something like this
.mixin(@class1, @class2) {
   [email protected]{class1} {
/* тут хочется как-то выполнить @class2 */
   }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Malinochkin, 2015-07-26
@DiAsCrafts

You can organize this using a set of rules (ruleset).

.mixin() {
  color: red;
}

@name: {
  .mixin();
};


.class {
  @name();
}

Documentation: click .
A little in Russian: click .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question