-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
LESS WEB DEVELOPMENT COOKBOOK
By :
Less also runs inside Rhino, which is an open source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. Rhino enables you to use the original less.js distribution in a pure JVM environment.
To use less.js inside Rhino, you will have to download and install Rhino from the following links:
less-rhino-x.x.x.js and lessc-rhino-x.x.x.js from https://github.com/less/less.js/tree/master/distexample.less. The example.less file can contain, for instance, the following code:@base-color: red;
h1 {
color: @base-color;
}java -jar js.jar -f less-rhino-1.7.0.js lessc-rhino-1.7.0.js example.less
h1 {
color: #ff0000;
}Rhino enables Java to run the JavaScript code, while js.jar runs the Less compiler and generates the CSS output.
To write the output of a file, you will have to append the filename of the CSS files to the list of commands, as follows:
java -jar js.jar -f less-rhino-1.7.0.js lessc-rhino-1.7.0.js example.less example.css
You can also add options for the compiler. You can add the -x option to compress the output as follows:
java -jar js.jar -f less-rhino-1.7.0.js lessc-rhino-1.7.0.js -x example.less
The preceding command will then output the following line of CSS code:
h1{color:#f00}
A Less compiler for Java has been built with Rhino. You can find out more information about this Less compiler for Java along with how to download it at https://github.com/marceloverdijk/lesscss-java.
Change the font size
Change margin width
Change background colour