Examples of JapidTemplate


Examples of cn.bran.japid.template.JapidTemplate

    contents.close();

    String fileName = srcFile.getProjectRelativePath().toString().substring("app/".length());
    // the compiler assumes the path separator is system specific separator
    fileName = fileName.replace('/', File.separatorChar);
    JapidTemplate temp = new JapidTemplate(fileName, src);
    JapidAbstractCompiler c = null;
    if (JapidTemplateTransformer.looksLikeLayout(src)) {
      c = new JapidLayoutCompiler();
    } else {
      // regular template and tag are the same thing
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

    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);
  }
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

        // compile the target and include the layout part in the current output flow
        String target = parseInclude(line);
        String src;
        try {
          src = DirUtil.readFileAsString(target);
          JapidTemplate template = new JapidTemplate(target, src);
          JapidAbstractCompiler c = JapidTemplateTransformer.selectCompiler(src);
          c.setUseWithPlay(getTemplateClassMetaData().useWithPlay);
          c.compile(template);
          String jsrc = template.javaSource;
          getTemplateClassMetaData().merge(c.getTemplateClassMetaData());
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

                throw new RuntimeException("no source file for compiling " + className);
             
              if (rc.getOriSourceCode() == null)
                throw new RuntimeException("no original source code for compiling " + className);
             
              JapidTemplate tmpl = new JapidTemplate(rc.getSrcFile().getPath(), rc.getOriSourceCode());
              throw new JapidCompilationException(
                  tmpl,
                  DirUtil.mapJavaLineToSrcLine(rc.getSourceCode(), problem.getSourceLineNumber()),
                  message + " while compiling " + className
                  );
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

   * @throws Exception
   */
  public File generate(String fileName) throws Exception {
    String realSrcFile = sourceFolder == null ? fileName : sourceFolder + "/" + fileName;
    String src = DirUtil.readFileAsString(realSrcFile);
    JapidTemplate temp = new JapidTemplate(fileName, src);
    JapidAbstractCompiler c = selectCompiler(src);
    c.setUseWithPlay(usePlay);
    c.compile(temp);
    String jsrc = temp.javaSource;

View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

   * @param srcFileName the full path to the script file. Used to parse package and class name
   * @return the generated Java code
   *
   */
  public static String generateInMemory(String scriptSrc,  String srcFileName, boolean usePlay) {
    JapidTemplate temp = new JapidTemplate(srcFileName, scriptSrc);
    return compileJapid(scriptSrc, usePlay, temp);
  }
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

public class CompilerTests {

  @Test
  public void testOpenFor() throws IOException {
    String src = readFile("tests/openFor.html");
    JapidTemplate bt = new JapidTemplate("tests/openFor.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

  }

  @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));
  }
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

  }
 
  @Test
  public void testIfCommand() throws IOException {
    String src = readFile("JapidSample/app/japidviews/Application/ifs.html");
    JapidTemplate bt = new JapidTemplate("Application/ifs.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    String javaSource = bt.javaSource;
    System.out.println(javaSource);
    assertTrue(javaSource.contains("if(!asBoolean(ss))"));
View Full Code Here

Examples of cn.bran.japid.template.JapidTemplate

  }
 
  @Test
  public void testOpenIfCommand() throws IOException {
    String src = readFile("JapidSample/app/japidviews/Application/ifs2.html");
    JapidTemplate bt = new JapidTemplate("Application/ifs2.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.