Search in sources :

Example 16 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testTagline.

@Test
public void testTagline() throws IOException, ParseException {
    String srcFile = "tests/tagline.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("tagline.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String code = bt.javaSource;
    System.out.println(code);
    CompilationUnit cu = JavaSyntaxTool.parse(code);
//		System.out.println(cu);
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 17 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testTagNamedArgsWithBody.

@Test
public void testTagNamedArgsWithBody() throws IOException, ParseException {
    String srcFile = "tests/callTagWithBody.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("tests/callTagWithBody.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String code = bt.javaSource;
    assertTrue("invalid java code", JavaSyntaxTool.isValid(code));
    System.out.println(code);
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 18 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testInclude.

@Test
public void testInclude() throws IOException, ParseException {
    String srcFile = "tests/include.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));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 19 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testTemplateWithCallbackTagCalls.

@Test
public void testTemplateWithCallbackTagCalls() throws IOException, ParseException {
    String src = readFile("JapidSample/app/japidviews/templates/AllPost.html");
    JapidTemplate bt = new JapidTemplate("japidviews/templates/AllPost.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
//		assertTrue("invalid java code", JavaSyntaxValidator.isValid(bt.javaSource));
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 20 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testLog.

@Test
public void testLog() throws IOException, ParseException {
    String srcFile = "JapidSample/app/japidviews/templates/log.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("japidviews/templates/Actions.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Aggregations

JapidAbstractCompiler (cn.bran.japid.compiler.JapidAbstractCompiler)29 JapidTemplateCompiler (cn.bran.japid.compiler.JapidTemplateCompiler)29 JapidTemplate (cn.bran.japid.template.JapidTemplate)29 Test (org.junit.Test)29 CompilationUnit (japa.parser.ast.CompilationUnit)9