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));
}
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);
}
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));
}
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)"));
}
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"));
}
Aggregations