The built-in functions are grouped as the type functions that can be used to evaluate the type of a value. The result can be used to match mixins based on the value type.
For this recipe, you will need a text editor and the command-line lessc
compiler ready, as described in the Installing the lessc compiler with npm recipe in Chapter 1, Getting to Grips with the Basics of Less.
Write the following code into a Less file and compile this file with the command-line
lessc
compiler:color-tstt(@color,@test-number) when (iscolor(@color)) { result-@{test-number}: %("%a is a color",@color); } .color-test(@color,@test-number) when (default()) { result-@{test-number}: %("%a is Not a color",@color); } test { .color-test(blue,1); .color-test("blue",2); .color-test(color("blue"),3); .color-test(~"blue",4); }
The preceding Less code will compile into the following CSS code:
test { result-1: "#0000ff is a color"; result-2: ""blue" is Not...