|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.github.marceloverdijk.lesscss4j.LessCompiler
public class LessCompiler
The LESS compiler to compile LESS sources to CSS stylesheets.
The compiler uses Rhino (JavaScript implementation written in Java), Envjs
(simulated browser environment written in JavaScript), and the official LESS
JavaScript compiler.
Note that lesscss4j is not a Java implementation of LESS itself, but rather
integrates the LESS JavaScript compiler within a Java/JavaScript browser
environment provided by Rhino and Envjs.
Lesscss4j comes bundled with the Envjs and LESS JavaScript, so there is no need to include them yourself. But if needed they can be overridden.
LessCompiler lessCompiler = new LessCompiler();
String css = lessCompiler.compile("@color: #4D926F; #header { color: @color; }");
| Constructor Summary | |
|---|---|
LessCompiler()
Constructs a new LessCompiler. |
|
| Method Summary | |
|---|---|
String |
compile(File input)
Compiles the LESS input File to CSS. |
void |
compile(File input,
File output)
Compiles the LESS input File to CSS and writes it to the specified output File. |
void |
compile(File input,
File output,
boolean force)
Compiles the LESS input File to CSS and writes it to the specified output File. |
String |
compile(LessSource input)
Compiles the input LessSource to CSS. |
void |
compile(LessSource input,
File output)
Compiles the input LessSource to CSS and writes it to the specified output File. |
void |
compile(LessSource input,
File output,
boolean force)
Compiles the input LessSource to CSS and writes it to the specified output File. |
String |
compile(String input)
Compiles the LESS input String to CSS. |
List<URL> |
getCustomJs()
Returns the custom JavaScript files used by the compiler. |
String |
getEncoding()
Returns the character encoding used by the compiler when writing the output File. |
URL |
getEnvJs()
Returns the Envjs JavaScript file used by the compiler. |
URL |
getLessJs()
Returns the LESS JavaScript file used by the compiler. |
void |
init()
Initializes this LessCompiler. |
boolean |
isCompress()
Returns whether the compiler will compress the CSS. |
void |
setCompress(boolean compress)
Sets the compiler to compress the CSS. |
void |
setCustomJs(List<URL> customJs)
Sets the custom JavaScript files used by the compiler. |
void |
setCustomJs(URL customJs)
Sets a single custom JavaScript file used by the compiler. |
void |
setEncoding(String encoding)
Sets the character encoding used by the compiler when writing the output File. |
void |
setEnvJs(URL envJs)
Sets the Envjs JavaScript file used by the compiler. |
void |
setLessJs(URL lessJs)
Sets the LESS JavaScript file used by the compiler. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LessCompiler()
LessCompiler.
| Method Detail |
|---|
public URL getEnvJs()
public void setEnvJs(URL envJs)
init() is called.
envJs - The Envjs JavaScript file used by the compiler.public URL getLessJs()
public void setLessJs(URL lessJs)
init() is called.
The - LESS JavaScript file used by the compiler.public List<URL> getCustomJs()
public void setCustomJs(URL customJs)
init() is called.
customJs - A single custom JavaScript file used by the compiler.public void setCustomJs(List<URL> customJs)
init() is called.
customJs - The custom JavaScript files used by the compiler.public boolean isCompress()
public void setCompress(boolean compress)
compress - If true, sets the compiler to compress the CSS.public String getEncoding()
File.
File.public void setEncoding(String encoding)
File.
If not set the platform default will be used.
The - character encoding used by the compiler when writing the output File.public void init()
LessCompiler.
It is not needed to call this method manually, as it is called implicitly by the compile methods if needed.
public String compile(String input)
throws LessException
String to CSS.
input - The LESS input String to compile.
LessException
public String compile(File input)
throws IOException,
LessException
File to CSS.
input - The LESS input File to compile.
IOException - If the LESS file cannot be read.
LessException
public void compile(File input,
File output)
throws IOException,
LessException
File to CSS and writes it to the specified output File.
input - The LESS input File to compile.output - The output File to write the CSS to.
IOException - If the LESS file cannot be read or the output file cannot be written.
LessException
public void compile(File input,
File output,
boolean force)
throws IOException,
LessException
File to CSS and writes it to the specified output File.
input - The LESS input File to compile.output - The output File to write the CSS to.force - 'false' to only compile the LESS input file in case the LESS source has been modified (including imports) or the output file does not exists.
IOException - If the LESS file cannot be read or the output file cannot be written.
LessException
public String compile(LessSource input)
throws LessException
LessSource to CSS.
input - The input LessSource to compile.
LessException
public void compile(LessSource input,
File output)
throws IOException,
LessException
LessSource to CSS and writes it to the specified output File.
input - The input LessSource to compile.output - The output File to write the CSS to.
IOException - If the LESS file cannot be read or the output file cannot be written.
LessException
public void compile(LessSource input,
File output,
boolean force)
throws IOException,
LessException
LessSource to CSS and writes it to the specified output File.
input - The input LessSource to compile.output - The output File to write the CSS to.force - 'false' to only compile the input LessSource in case the LESS source has been modified (including imports) or the output file does not exists.
IOException - If the LESS file cannot be read or the output file cannot be written.
LessException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||