Package cn.bran.japid.compiler

Examples of cn.bran.japid.compiler.JapidTemplateCompiler


    JapidAbstractCompiler c = null;
    if (JapidTemplateTransformer.looksLikeLayout(src)) {
      c = new JapidLayoutCompiler();
    } else {
      // regular template and tag are the same thing
      c = new JapidTemplateCompiler();
    }

    c.compile(temp);
    // now we have the derived source
    String text = temp.javaSource;
View Full Code Here


 
  @Test
  public void testOpenIfCommand() throws IOException {
    String src = readFile("JapidSample/app/japidviews/Application/ifs2.html");
    JapidTemplate bt = new JapidTemplate("Application/ifs2.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

 
  @Test
  public void testExtendsLayoutWithArgs() throws IOException {
    String src = readFile("JapidSample/app/japidviews/more/Perf/perf.html");
    JapidTemplate bt = new JapidTemplate("more/Perf/perf.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

  @Test
  public void testReverse() throws IOException {
    String path = "tests/reverse.html";
    String src = readFile(path);
    JapidTemplate bt = new JapidTemplate(path, src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srccode = bt.javaSource;
    System.out.println(srccode);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(srccode));
    assertTrue(srccode.contains("p(lookupStatic(\"/x/y.html\"))"));
    assertTrue(srccode.contains("p(lookupStatic(\"/a/b/c.html\"))"));
View Full Code Here

  @Test
  public void testTemplateWithCallbackTagCalls() throws IOException, ParseException {
    String src = readFile("JapidSample/app/japidviews/templates/AllPost.html");

    JapidTemplate bt = new JapidTemplate("japidviews/templates/AllPost.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
//    assertTrue("invalid java code", JavaSyntaxValidator.isValid(bt.javaSource));
   
View Full Code Here

  @Test
  public void testOpenForInDef() throws IOException, ParseException {
    String src = readFile("tests/openForInDef.html");
   
    JapidTemplate bt = new JapidTemplate("tests/openForInDef.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
//    assertTrue("invalid java code", JavaSyntaxValidator.isValid(bt.javaSource));
   
View Full Code Here

  @Test
  public void testCompileTagWithDoubleDispatch() throws IOException, ParseException {
    String src = readFile("JapidSample/app/japidviews/_tags/Display.html");
    JapidTemplate bt = new JapidTemplate("tags/Display.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    System.out.println(srcCode);
   
    CompilationUnit cu = JavaSyntaxTool.parse(srcCode);
    assertTrue(srcCode.contains("package tags;"));
View Full Code Here

 
  @Test
  public void testIfindef() throws IOException, ParseException {
    String src = readFile("tests/ifindef.html");
    JapidTemplate bt = new JapidTemplate("tests/ifindef.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
//    System.out.println(srcCode);
    assertTrue(!srcCode.contains("_if"));
  }
View Full Code Here

 
  @Test
  public void testElvis() throws IOException, ParseException {
    String src = readFile("tests/elvis.html");
    JapidTemplate bt = new JapidTemplate("tests/elvis.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    System.out.println(srcCode);
  }
View Full Code Here

 
  @Test
  public void testOpenIf() throws IOException, ParseException {
    String src = readFile("tests/openif.html");
    JapidTemplate bt = new JapidTemplate("tests/openif.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    System.out.println(srcCode);
    CompilationUnit cu = JavaSyntaxTool.parse(srcCode);
  }
View Full Code Here

TOP

Related Classes of cn.bran.japid.compiler.JapidTemplateCompiler

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.