use of cn.bran.japid.compiler.JapidAbstractCompiler 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.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testOpenBrace.
@Test
public void testOpenBrace() throws IOException {
String srcFile = "tests/openBrace.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate(srcFile, 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.JapidAbstractCompiler 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.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testSimpleInvoke.
@Test
public void testSimpleInvoke() throws IOException {
String srcFile = "tests/simpleInvoke.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("simpleInvoke.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("actionRunners.put(getOut().length(), new cn.bran.play.CacheablePlayActionRunner(\"\", MyController.class, \"action\", s + \"2\") {"));
assertTrue(code.contains("MyController.action(s);"));
assertTrue(code.contains("MyController.action(s + \"2\");"));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testActionNotation.
@Test
public void testActionNotation() throws IOException {
String src = readFile("JapidSample/app/japidviews/templates/Actions.html");
JapidTemplate bt = new JapidTemplate("japidviews/templates/Actions.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
Aggregations