Search in sources :

Example 31 with JapidTemplate

use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.

the class CompilerTests method testTemplateWithCallbackTagCalls.

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

Example 32 with JapidTemplate

use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.

the class CompilerTests method testLog.

@Test
public void testLog() throws IOException, ParseException {
    String srcFile = "JapidSample/app/japidviews/templates/log.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("japidviews/templates/Actions.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 33 with JapidTemplate

use of cn.bran.japid.template.JapidTemplate 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 34 with JapidTemplate

use of cn.bran.japid.template.JapidTemplate 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 35 with JapidTemplate

use of cn.bran.japid.template.JapidTemplate 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)

Aggregations

JapidTemplate (cn.bran.japid.template.JapidTemplate)44 JapidAbstractCompiler (cn.bran.japid.compiler.JapidAbstractCompiler)39 Test (org.junit.Test)39 JapidTemplateCompiler (cn.bran.japid.compiler.JapidTemplateCompiler)29 CompilationUnit (japa.parser.ast.CompilationUnit)12 JapidLayoutCompiler (cn.bran.japid.compiler.JapidLayoutCompiler)10 TagIf (cn.bran.japid.compiler.Tag.TagIf)2 TagInTag (cn.bran.japid.compiler.Tag.TagInTag)2 File (java.io.File)2 Matcher (java.util.regex.Matcher)2 JapidCompilationException (cn.bran.japid.compiler.JapidCompilationException)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 CategorizedProblem (org.eclipse.jdt.core.compiler.CategorizedProblem)1 IProblem (org.eclipse.jdt.core.compiler.IProblem)1 ClassFile (org.eclipse.jdt.internal.compiler.ClassFile)1