Skip to content

Dynamic mixin calling #617

Closed
Closed

Description

@Anahkiasen

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.

Activity

  1. turboelk commented on Feb 14, 2012

    @turboelk
    @blue: blue;
    @red: red;
    
    .color (@color) {
        color: @@color;
    }
    
    div {
        .color(red);
    }

    Resulting in

    div {
        color: red;
    }

    Could be a substitution?

  2. lukeapage commented on Feb 25, 2013

    @lukeapage
    Member

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

    [edit - example corrected]

  3. Soviut commented on Feb 26, 2013

    @Soviut

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions