0

Using variable on mixin or extend in Less.js as follow will throw error.

@bar : bar;

.@{bar} {
  background: yellow;
}

// ParseError: Missing closing ')'
.foo {
  .@{bar}(); 
}

// Not work
.jam {
  &:extend(.@{bar});
}

Has Less.js a proper syntax to call mixin with variables?

2
  • 1
    In short, no. The corresponding feature for extend is proposed at #1485. Commented Jan 18, 2016 at 12:10
  • 1
    As for mixins - these days it's not really recommended to re-use existing CSS rulesets as mixins for various reasons, so this feature is not planned (though it will be probably supported indirectly by other additions). Thus for your use-case you're probably better to start with something like this. Commented Jan 18, 2016 at 12:10

1 Answer 1

3

You are trying to call a mixin using selector interpolation, which is not possible.

As for extend, Less documentation states it clearly:

Extend is NOT able to match selectors with variables. If selector contains variable, extend will ignore it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.