use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.
the class CompilerTests method testOpenIf.
@Test
public void testOpenIf() throws IOException, ParseException {
String src = readFile("tests/openif.html");
JapidTemplate bt = new JapidTemplate("tests/openif.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.template.JapidTemplate 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.template.JapidTemplate 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.template.JapidTemplate in project Japid by branaway.
the class CompilerTests method testScriptlineLayout.
@Test
public void testScriptlineLayout() throws IOException {
String srcFile = "JapidSample/app/japidviews/more/MyController/scriptlineLayout.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("scriptlineLayout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String code = bt.javaSource;
System.out.println(code);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
use of cn.bran.japid.template.JapidTemplate in project Japid by branaway.
the class CompilerTests method testSubLayout.
@Test
public void testSubLayout() throws IOException {
String src = readFile("JapidSample/app/japidviews/_layouts/SubLayout.html");
JapidTemplate bt = new JapidTemplate("japidviews/_layouts/SubLayout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
assertTrue(srccode.contains("package japidviews._layouts;"));
assertTrue(srccode.contains("public abstract class SubLayout extends Layout"));
assertTrue(srccode.contains("protected abstract void doLayout();"));
assertTrue(srccode.contains("@Override public void layout()"));
}
Aggregations