Package com.github.sommeri.less4j

Examples of com.github.sommeri.less4j.LessCompiler


    return lessValue;
  }

  @Override
  public InputStream open(String s, URLConnection resource) throws IOException {
    LessCompiler compiler = new ThreadUnsafeLessCompiler();
    try {
      LessCompiler.CompilationResult result = compiler.compile(resource.getURL());
      return new ByteArrayInputStream(result.getCss().getBytes());
    }
    catch (Less4jException e) {
      List<LessCompiler.Problem> errors = e.getErrors();
      ArrayList<Message> messages = new ArrayList<Message>(errors.size());
View Full Code Here


    customFunctionExample();
  }

  private static void basicFileExample() throws Less4jException {
    File inputLessFile = createFile("sampleInput.less", "* { margin: 1 1 1 1; }");
    LessCompiler compiler = new ThreadUnsafeLessCompiler();
    CompilationResult compilationResult = compiler.compile(inputLessFile);

    System.out.println(compilationResult.getCss());
    for (Problem warning : compilationResult.getWarnings()) {
      System.err.println(format(warning));
    }
View Full Code Here

  private static void guessedCssLocationExample1() throws Less4jException {
    File inputLessFile = createFile("src/sampleInput.less", ".class { margin: 1 1 1 1; }");

    File lessFile = new File("src/sampleInput.less").getAbsoluteFile();
   
    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(lessFile);

    System.out.println(compilationResult.getCss());
    System.out.println(compilationResult.getSourceMap());

    deleteFile(inputLessFile);
View Full Code Here

  private static void guessedCssLocationExample2() throws Less4jException {
    URI uri = (new File("src/sampleInput.less")).toURI();
    StringSource lessSource = new StringSource(".class { margin: 1 1 1 1; }", "sampleInput.less", uri);
   
    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(lessSource);

    System.out.println(compilationResult.getCss());
    System.out.println(compilationResult.getSourceMap());

  }
View Full Code Here

    File cssFile = new File("dist/sampleInput.css").getAbsoluteFile();
   
    Configuration configuration = new Configuration();
    configuration.setCssResultLocation(cssFile);
   
    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(lessFile, configuration);

    System.out.println(compilationResult.getCss());
    System.out.println(compilationResult.getSourceMap());

    deleteFile(inputLessFile);
View Full Code Here

    configuration.setCssResultLocation(cssFile);

    URI uri = (new File("src/sampleInput.less")).toURI();
    StringSource lessSource = new StringSource(".class { margin: 1 1 1 1; }", "sampleInput.less", uri);
   
    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(lessSource, configuration);

    System.out.println(compilationResult.getCss());
    System.out.println(compilationResult.getSourceMap());
  }
View Full Code Here

    "}");

    Configuration configuration = new Configuration();
    configuration.addCustomFunction(new ConstantFunction());

    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(inputLessFile, configuration);

    System.out.println(compilationResult.getCss());
    deleteFile(inputLessFile);
  }
View Full Code Here

  }

  private void expectCompileError(String less, String expectedError) {
    StringSource lessSource = new StringSource(less);
    try {
      LessCompiler compiler = new DefaultLessCompiler();
      compiler.compile(lessSource);
    } catch (Less4jException e) {
      assertFalse(e.getErrors().isEmpty());
      assertEquals(expectedError, e.getMessage());
      return ;
    }
View Full Code Here

    LESS_INPUT_CONTENTS.put(null, NO_IMPORT_LESS_INPUT);
  }
 
  @Test
  public void string() throws Less4jException {
    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(NO_IMPORT_LESS_INPUT);
   
    assertNotNull(compilationResult.getCss());
    assertNotNull(compilationResult.getSourceMap());
    assertDoesNotLinkSourceMap(compilationResult.getCss());
   
View Full Code Here

    validator.validateSourceMap(compilationResult, new File(NO_DATA_AVAILABLE_MAPDATA));
  }

  @Test
  public void stringWithEmptyConfiguration() throws Less4jException {
    LessCompiler compiler = new DefaultLessCompiler();
    CompilationResult compilationResult = compiler.compile(NO_IMPORT_LESS_INPUT, new Configuration());
   
    assertNotNull(compilationResult.getCss());
    assertNotNull(compilationResult.getSourceMap());
    assertDoesNotLinkSourceMap(compilationResult.getCss());
   
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.LessCompiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.