|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcn.dreampie.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 the compiler 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.
The compiler 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; }");
| 构造方法摘要 | |
|---|---|
LessCompiler()
Constructs a new LessCompiler. |
|
LessCompiler(List<String> options)
Constructs a new LessCompiler. |
|
| 方法摘要 | |
|---|---|
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(File input,
String name)
Compiles the LESS input String to CSS, but specifies the source name String. |
String |
compile(LessSource input)
|
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. |
String |
compile(String input,
String name)
Compiles the LESS input String to CSS, but specifies the source name String. |
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 |
getLesscJs()
Returns the LESSC JavaScript file used by the compiler. |
URL |
getLessJs()
Returns the LESS JavaScript file used by the compiler. |
List<String> |
getOptions()
|
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 |
setLesscJs(URL lesscJs)
Sets the LESSC JavaScript file used by the compiler. |
void |
setLessJs(URL lessJs)
Sets the LESS JavaScript file used by the compiler. |
void |
setOptions(List<String> options)
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public LessCompiler()
LessCompiler.
public LessCompiler(List<String> options)
LessCompiler.
| 方法详细信息 |
|---|
public List<String> getOptions()
public void setOptions(List<String> options)
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.
lessJs - LESS JavaScript file used by the compiler.public URL getLesscJs()
public void setLesscJs(URL lesscJs)
init() is called.
lesscJs - LESSC 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)
init() is called.
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.
Must be set before init() is called.
encoding - 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(String input,
String name)
throws LessException
String to CSS, but specifies the source name String.
input - The LESS input String to compilename - The source's name String to provide better error messages.
LessException - any error encountered by the compiler
public String compile(File input,
String name)
throws LessException
String to CSS, but specifies the source name String. The entire
method is synchronized so that two threads don't read the output at the same time.
input - The LESS input String to compilename - The source's name String to provide better error messages.
LessException - any error encountered by the compiler
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
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
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||