Search in sources :

Example 1 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler 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));
}
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 2 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler 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\");"));
}
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 3 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler 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));
}
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 4 with JapidTemplateCompiler

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

the class CompilerTests method testVerbatim.

@Test
public void testVerbatim() throws IOException, ParseException {
    String srcFile = "JapidSample/app/japidviews/Application/verbatim.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("japidviews/Application/verbatim.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)

Example 5 with JapidTemplateCompiler

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

the class CompilerTests method testDoBodyInDef.

@Test
public void testDoBodyInDef() throws IOException {
    String srcFile = "tests/doBodyInDef.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("doBodyInDef.html", 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)

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