public String compile(URL input) throws LessException, IOException { return compile(input, false); }
public void compile(File input, File output) throws LessException, IOException { compile(input, output, false); }
public String compile(String input, String location) throws LessException { return compile(input, location, false); }
public String compile(String input) throws LessException { return compile(input, false); }
public String compile(URL input) throws LessException { return compile(input, false); }
public String compile(String input) throws LessException { return compile(input, null, false); }
public String compile(File input) throws LessException, IOException { return compile(input, false); }
public void compile(File input, File output) throws LessException, IOException { compile(input, output, false); }
public String compile(File input) throws LessException { return compile(input, false); }
public void compile(File input, File output, boolean compress) throws LessException, IOException { String content = compile(input, compress); if (!output.exists()) { output.createNewFile(); } BufferedWriter bw = new BufferedWriter(new FileWriter(output)); bw.write(content); bw.close(); }
private String getCompiled() throws Exception { try (InputStream in = this.getClass().getResourceAsStream(lessResourceName)) { checkNotNull(in, "Could not find resource: " + lessResourceName); try (StringWriter writer = new StringWriter()) { IOUtils.copy(in, writer, StandardCharsets.UTF_8); String inputLess = writer.toString(); return lessCompiler().compile(inputLess); } } }
public void compile(File input, File output, boolean compress) throws LessException, IOException { try { String content = compile(input, compress); if (!output.exists()) { output.createNewFile(); } BufferedWriter bw = new BufferedWriter(new FileWriter(output)); bw.write(content); bw.close(); } catch (Exception e) { throw parseLessException(e); } }
@Override protected byte[] compile(final ICombinedLessResource lessFile) { final long start = System.currentTimeMillis(); try { return getLessEngine().compile(lessFile.asText()).getBytes(getCharset()); } catch (LessException e) { return handleException(e); } finally { LOG.debug("duration of less compiler for {}: {} ms", lessFile.getName(), System.currentTimeMillis() - start); } } };
public void appendLessResource(String pathInfo) { try (InputStream in = this.getClass().getResourceAsStream(pathInfo)) { checkNotNull(in, "Could not find resource: " + pathInfo); try (StringWriter writer = new StringWriter()) { IOUtils.copy(in, writer, StandardCharsets.UTF_8); String inputLess = writer.toString(); String output = lessCompiler().compile(inputLess); appendCss(output); } } catch (Exception ex) { throw new VisalloException("Could not append less resource: " + pathInfo, ex); } }
public String run(String content) throws IOException { LessOptions options = new LessOptions(); ResourceLoader resourceLoader = new ScoutClasspathResourceLoader(LessEngine.class.getClassLoader()); LessEngine engine = new LessEngine(options, resourceLoader); try { return engine.compile(content); } catch (LessException e) { throw new IOException("Failed to parse CSS content with LESS", e); } }
public byte[] getContent() throws LessException, IOException { if (content == null || !cache) { logger.debug("Not using cache."); if (engine != null) { logger.debug("LessEngine available, compiling."); content = (resource instanceof URL ? engine .compile((URL) resource) : engine .compile((File) resource)).replaceAll("\\\\n", "\n") .getBytes(charset); } else { logger.debug("LessEngine not available, treating as regular resource."); content = resource instanceof URL ? ResourceUtils.readTextUrl( (URL) resource, charset) : ResourceUtils.readTextFile( (File) resource, charset); } lastModified = super.getLastModified(); if (compress) { logger.debug("Compressing resource."); compress(); } } else { logger.debug("Using cache, since lastModified: " + lastModified + " and getLastModified: " + getLastModified()); } return content; }
public String compile(Object input, String themeName, String location) throws LessException { String source = SyntaxHelper.encodeDsp(loadSource(input), themeName); String result = null; result = compiler.compile(source, location); return SyntaxHelper.decodeDsp(result); }
/** * Overrides the default implementation to add LESS processing capabilities. * * @param path The path of the file being processed (used only for error output) * @param cssContents The CSS to process * @throws IOException when accessing file contents. */ @Override public String processCssThemes(String path, StringBuilder cssContents) throws IOException { String compiledCss = null; String fullCSS = this.getLessVariables() + cssContents; try { compiledCss = this.engine.compile(fullCSS); } catch (LessException e) { compiledCss = "/*" + logLessException(e, path) + "*/\n\n " + cssContents; } catch (ClassCastException e) { compiledCss = "/*" + logLessException(e, path) + "*/\n\n " + cssContents; } return compiledCss; } }
/** * Overrides the default implementation to add LESS processing capabilities. * * @param path The path of the file being processed (used only for error output) * @param cssContents The CSS to process * @throws IOException when accessing file contents. */ @Override public String processCssThemes(String path, StringBuilder cssContents) throws IOException { String compiledCss = null; String fullCSS = this.getLessVariables() + cssContents; try { compiledCss = this.engine.compile(fullCSS); } catch (LessException e) { compiledCss = "/*" + LessForJavaCssThemeHandler.logLessException(e, path) + "*/\n\n " + cssContents; } catch (ClassCastException e) { compiledCss = "/*" + LessForJavaCssThemeHandler.logLessException(e, path) + "*/\n\n " + cssContents; } return compiledCss; }
/** * Overrides the default implementation to add LESS processing capabilities. * * @param path The path of the file being processed (used only for error output) * @param cssContents The CSS to process * @throws IOException when accessing file contents. */ @Override public String processCssThemes(String path, StringBuilder cssContents) throws IOException { String compiledCss = null; String intialProcessResults = super.processCssThemes(path, cssContents); String lessVariables = this.getLessVariables(); String fullCSS = lessVariables + intialProcessResults; try { compiledCss = this.engine.compile(fullCSS.toString()); } catch (LessException e) { compiledCss = "/*" + LessForJavaCssThemeHandler.logLessException(e, path) + "*/\n\n " + intialProcessResults; } catch (ClassCastException e) { compiledCss = "/*" + LessForJavaCssThemeHandler.logLessException(e, path) + "*/\n\n " + intialProcessResults; } return compiledCss; } }