3

This is how I wrote it, but I get

Parse Error: Unrecognised Input

How can I circumvent this?

I do not want to declare individual mixin for focus, active and disabled states.

I am using WinLess for compiling on Windows 7.

  • WinLess version:1.9.1
  • Less.js version:2.1.2

Here is my code

.state(@state,@property,@colour){
    &:@{state}{
        @{property}:@colour;
    }
}

Any help is appreciated.

Harry
  • 87,580
  • 25
  • 202
  • 214
vssadineni
  • 454
  • 4
  • 11
  • Can't you upgrade to the latest version of the compiler? The code should work fine as-is. – Harry Nov 03 '15 at 10:38

1 Answers1

4

The best solution to is to update your Less.js compiler to the latest version (v 2.5.3) because it compiles the code provided in the question as-is without the need for any modifications.

However, if you can't upgrade the compiler for whatever reasons then you would need an intermediate variable to form the pseudo-class selectors and then use them like in the below snippet:

.state(@state,@property,@colour){
  @sel: ~":@{state}";
  &@{sel}{
    @{property}:@colour;
  }
}
#demo{
  .state(hover,color,red);
}
Harry
  • 87,580
  • 25
  • 202
  • 214