use of cn.bran.japid.template.JapidTemplate 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));
}
use of cn.bran.japid.template.JapidTemplate 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"));
}
use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.
the class CompilerTests method testNamedParams.
@Test
public void testNamedParams() throws IOException, ParseException {
String srcFile = "tests/namedParam.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("tests/namedParam.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("new person(namedParam.this).render(named(\"name\", \"Bing\"), named(\"age\", foo(18)))"));
// assertTrue(bt.javaSource.contains("@Override protected void title() {"));
}
use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.
the class CompilerTests method testAnotherLayout.
@Test
public void testAnotherLayout() throws IOException, ParseException {
String src = readFile("JapidSample/app/japidviews/_layouts/TagLayout.html");
JapidTemplate bt = new JapidTemplate("japidviews/_layouts/TagLayout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
CompilationUnit cu = JavaSyntaxTool.parse(srccode);
assertTrue(srccode.contains("package japidviews._layouts;"));
assertTrue(srccode.contains("public abstract class TagLayout extends cn.bran.play.JapidTemplateBase"));
assertTrue(srccode.contains("protected abstract void doLayout();"));
assertTrue(srccode.contains("@Override public void layout()"));
}
use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.
the class CompilerTests method testElvis.
@Test
public void testElvis() throws IOException, ParseException {
String src = readFile("tests/elvis.html");
JapidTemplate bt = new JapidTemplate("tests/elvis.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
String srcCode = bt.javaSource;
System.out.println(srcCode);
}
Aggregations