com.clickntap.utils.LessUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Stripecube Show documentation
Show all versions of Stripecube Show documentation
Stripecube is an open source Java framework for Web Applications
package com.clickntap.utils;
import com.asual.lesscss.LessEngine;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
public class LessUtils {
public static LessEngine engine = new LessEngine();
public static synchronized String eval(String code) throws Exception {
return engine.compile(code);
}
public static synchronized void compile(String file) throws Exception {
LessUtils.compile(file, true);
}
public static synchronized void compile(File file) throws Exception {
LessUtils.compile(file, true);
}
public static synchronized void compile(String file, boolean compress) throws Exception {
LessUtils.compile(new File(file), compress);
}
public static synchronized void compile(File file, boolean compress) throws Exception {
String css = engine.compile(file, compress);
css = css.replace("-:;", "");
css = css.replace("-: ;", "");
FileUtils.writeByteArrayToFile(new File(file.getParent() + "/" + FilenameUtils.getBaseName(file.getName()) + ".css"), css.getBytes(ConstUtils.UTF_8));
}
}