Search in sources :

Example 1 with JapidLayoutCompiler

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);
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with JapidLayoutCompiler

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);
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) Test(org.junit.Test)

Example 3 with JapidLayoutCompiler

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));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) Test(org.junit.Test)

Example 4 with JapidLayoutCompiler

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()"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) Test(org.junit.Test)

Example 5 with JapidLayoutCompiler

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));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) Test(org.junit.Test)

Aggregations

JapidAbstractCompiler (cn.bran.japid.compiler.JapidAbstractCompiler)10 JapidLayoutCompiler (cn.bran.japid.compiler.JapidLayoutCompiler)10 JapidTemplate (cn.bran.japid.template.JapidTemplate)10 Test (org.junit.Test)10 CompilationUnit (japa.parser.ast.CompilationUnit)3 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1