-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a variable in a mixin call #2885
Comments
Currently it's impossible to call a mixin indirectly (i.e. by name as variable value). (The feature itself was proposed among other variations in #965 (comment). But since #965 itself is closed because its initial idea (DRs) is implement I suppose this one needs a dedicated ticket. So I'm not closing this one yet (but eventually it's most likely to be replaced by one with more detailed info). |
This would be a short-term fix. @lt: {
left:0;
top:0;
};
@n : lt;
@x : @@n;
@x(); And if you have multiple matching @lt: { .lt() };
.lt() {
left:0;
top:0;
}
.lt() {
color: red;
}
rules {
@n : lt;
@x : @@n;
@x();
}
// this will output
rules {
left: 0;
top: 0;
color: red;
} Unfortunately, there's an existing issue that prevents you from calling |
That's all too verbose. Old-school methods may result in a more compact workaround (though I'm intentionally not providing any in this case since it would be pretty useless w/o knowing the actual use-case/context (i.e. why exactly .lt() {
left: 0;
top: 0;
}
.n() {.lt}
.n();
// or:
@n: {.lt}
@n(); |
@matthew-dean @seven-phases-max Thanks to you all, I'll try them. and by the way, the script below can't compile succesfully, what's wrong with it ? .clouds(){
0% {
.l(-20%);
.opacity(.8);
}
50%{
.l(50%);
.opacity(.7);
}
100%{
.l(120%);
.opacity(.7);
}
}
.keyframes(@name,@mixin){
@keyframes @name{
@mixin();
}
@-webkit-keyframes @name{
@mixin();
}
}
.keyframes(cloud,.clouds()); It says "Syntax error expected ')' got '.' in (filename) on line 92, column 18:
How to use a mixin as a parameter?? Thanks... |
I've resolved myself........ |
Closing as N/A anymore. |
Such as
when I use a variable
The second line of the second passage of code, I want to call the
.lt()
. How to realize it? THANKS.The text was updated successfully, but these errors were encountered: