Search in sources :

Example 21 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testExtendsLayoutWithArgs.

@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));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 22 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testTagCalls.

@Test
public void testTagCalls() throws IOException {
    String srcFile = "tests/tagCalls.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("tagCalls.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String code = bt.javaSource;
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    System.out.println(code);
    //		assertTrue(code.contains("((tag)(new tag(getOut()).setActionRunners(getActionRunners()))).render(a)"));
    assertTrue(code.contains("new tag(tagCalls.this).render"));
    //		assertTrue(code.contains("((my.tag)(new my.tag(getOut())).setActionRunners(getActionRunners())).render(a, new my.tag.DoBody<String>(){"));
    assertTrue(code.contains("new my.tag(tagCalls.this).render"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 23 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testReverse.

@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\"))"));
    assertTrue(srccode.contains("p(lookup(\"com.action\", \"ad\"))"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 24 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testOpenIfCommand.

@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));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 25 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testRecursiveTags.

@Test
public void testRecursiveTags() throws IOException {
    String srcFile = "tests/recursiveTagging.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("tests/recursiveTagging.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String code = bt.javaSource;
    System.out.println(code);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    assertTrue(code.contains("new recursiveTagging(recursiveTagging.this).render"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Aggregations

JapidAbstractCompiler (cn.bran.japid.compiler.JapidAbstractCompiler)29 JapidTemplateCompiler (cn.bran.japid.compiler.JapidTemplateCompiler)29 JapidTemplate (cn.bran.japid.template.JapidTemplate)29 Test (org.junit.Test)29 CompilationUnit (japa.parser.ast.CompilationUnit)9