Skip to content
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

Dynamic mixin calling #617

Closed
Anahkiasen opened this issue Feb 3, 2012 · 3 comments
Closed

Dynamic mixin calling #617

Anahkiasen opened this issue Feb 3, 2012 · 3 comments

Comments

@Anahkiasen
Copy link

Not much to say, I just think it would be a good idea if in LESS you could do the following :

.blue { color: blue }
.red { color: red }

.color(@color) {
   .@{color}
}

div {
   .color(red)
}

Resulting in

div { color: red }

.@{variable} is a proposition of syntax but .@variable, .{variable} or .{@variable} would maybe fit better the LESS syntax, I don't know.

@Defavlt
Copy link

Defavlt commented Feb 14, 2012

@blue: blue;
@red: red;

.color (@color) {
    color: @@color;
}

div {
    .color(red);
}

Resulting in

div {
    color: red;
}

Could be a substitution?

@lukeapage
Copy link
Member

this can be achieved with mixin guards.. you would have .color when @color = red etc.

[edit - example corrected]

@Soviut
Copy link

Soviut commented Feb 26, 2013

guards use when not where, just a mild correction in case someone decides to cut and paste.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants