use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class BranLayoutCompilerTest method testHop.
@Test
public void testHop() throws IOException {
FileInputStream fis = new FileInputStream("JapidSample/app/japidviews/_layouts/Layout.html");
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String src = "";
for (String line = br.readLine(); line != null; line = br.readLine()) {
src += line + "\n";
}
JapidTemplate bt = new JapidTemplate("tag/Layout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
}
use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testNoPlayCommand.
@Test
public void testNoPlayCommand() throws IOException, ParseException {
String src = readFile("JapidSample/app/japidviews/templates/noplay.html");
JapidTemplate bt = new JapidTemplate("japidviews/templates/noplay.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
CompilationUnit cu = JavaSyntaxTool.parse(srccode);
}
use of cn.bran.japid.compiler.JapidLayoutCompiler 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.compiler.JapidLayoutCompiler 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()"));
}
use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testCompileLayout.
@Test
public void testCompileLayout() throws IOException {
String src = readFile("JapidSample/app/japidviews/_layouts/Layout.html");
JapidTemplate bt = new JapidTemplate("tag/Layout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
Aggregations