Mohamed El Mahallawy
Mohamed El Mahallawy

Reputation: 921

Less mixin variable call mixin

I have this very simple example as you can see:

.large{
  color: blue;
}

.a(@va){
  .large;
  ~".@{va}()";
}


a{
.a(large)
}

I keep trying to get the .large() or .large; to work by calling the .large mixin. I keep getting error:

Parse error: Unrecognised input
  .large;  ~".@{va}()";}

How can I fix this?

Upvotes: 1

Views: 261

Answers (1)

seven-phases-max
seven-phases-max

Reputation: 11820

You can't call a mixin by its name stored in a variable. You can achieve the goal by wrapping mixin call into "detached ruleset" though, e.g.:

.large {
    color: blue;
}

.a(@va) {
    @va();
}


a {
    .a({.large})
}

There're other methods of doing similar things (might be more useful/suitable depending on a use-case).

Upvotes: 2

Related Questions