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