-
Notifications
You must be signed in to change notification settings - Fork 44
Less Language Other Compiler Features
According to css specification, style sheet can have only one @charset declaration. In addition, css elements must be in following order:
-
@charsetstatement, -
@importstatements, - anything else.
Compiler enforce there rules by sorting top level declarations and removing all unnecessary @charset declarations.
If the ruleset contains the same declaration twice, only the last one is printed.
Sample input:
.numbers {
padding: 2; // this line will disappear - it is the same as the next one
padding: 2;
padding: 3; // this line will disappear - it is the same as the last one
padding: 2+3; // this line will disappear - it is the same as the next one
padding: 5;
padding: ~"3"
}
compiles into:
.numbers {
padding: 2;
padding: 5;
padding: 3;
}
Two declarations are considered equal if they would result in exactly the same line. Two lines differing only by comments are considered different. Compilation will keep this unchanged:
.numbers {
padding: /* comment */ 2;
padding: /* different */ 2;
}
As variable can reference any variable accessible in its scope, it is possible to create variable cycles:
// variables cycle
@first: @second;
@second: @first + 1;
.ruleset {
padding: @second;
}
Variables @first and @second references each other and it is impossible to evaluate their value. Less4j detects such cycles and reports them as errors:
ERROR 5:16 Cyclic references among variables: @second (5:16) -> @first (3:14) -> @second (2:13)
Source map support is described on another page.