Search in sources :

Example 1 with LessSource

use of com.github.sommeri.less4j.LessSource in project xwiki-platform by xwiki.

the class Less4jCompiler method compile.

/**
 * Compile the LESS code and get the included files from the skin templates.
 * @param lessCode code to compile
 * @param skin skin holding the templates
 * @param inlineSourceMap whether to create inline sourcemaps in the generated css
 * @return the results of the LESS compilation
 * @throws Less4jException if problems occur
 */
public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException {
    LessCompiler lessCompiler = new DefaultLessCompiler();
    LessCompiler.Configuration options = new LessCompiler.Configuration();
    options.setCompressing(true);
    options.getSourceMapConfiguration().setInline(inlineSourceMap);
    options.getSourceMapConfiguration().setIncludeSourcesContent(true);
    LessSource lessSource = new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin));
    LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options);
    return lessResult.getCss();
}
Also used : LessSource(com.github.sommeri.less4j.LessSource) DefaultLessCompiler(com.github.sommeri.less4j.core.DefaultLessCompiler) LessCompiler(com.github.sommeri.less4j.LessCompiler) DefaultLessCompiler(com.github.sommeri.less4j.core.DefaultLessCompiler)

Aggregations

LessCompiler (com.github.sommeri.less4j.LessCompiler)1 LessSource (com.github.sommeri.less4j.LessSource)1 DefaultLessCompiler (com.github.sommeri.less4j.core.DefaultLessCompiler)1