Search in sources :

Example 11 with JapidTemplateCompiler

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

the class CompilerTests method testElvisEscape.

@Test
public void testElvisEscape() throws IOException {
    String src = "~{ a ?: b}";
    JapidTemplate bt = new JapidTemplate("baba.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 12 with JapidTemplateCompiler

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

the class CompilerTests method testSwitch.

@Test
public void testSwitch() throws IOException, ParseException {
    String src = readFile("tests/switchCase.html");
    JapidTemplate bt = new JapidTemplate("tests/switchCase.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    System.out.println(srcCode);
    CompilationUnit cu = JavaSyntaxTool.parse(srcCode);
}
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 13 with JapidTemplateCompiler

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

the class CompilerTests method testOpenForInDef.

@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));
}
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 14 with JapidTemplateCompiler

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

the class CompilerTests method testTagBlock.

@Test
public void testTagBlock() throws IOException {
    String srcFile = "JapidSample/app/japidviews/templates/tagBody.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("japidviews/templates/tagBody.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    //		assertTrue(bt.javaSource.contains("((anotherTag)(new anotherTag(getOut())).setActionRunners(getActionRunners())).render(echo, new anotherTag.DoBody<String>(){"));
    assertTrue(bt.javaSource.contains("new moreTag(tagBody.this)"));
}
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 15 with JapidTemplateCompiler

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

the class CompilerTests method testEachDirective.

@Test
public void testEachDirective() throws IOException {
    String srcFile = "tests/eachTag.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("eachTag.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    assertFalse(bt.javaSource.contains("setActionRunners"));
}
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