Examples of TemplateFactory


Examples of com.firefly.template.TemplateFactory

   
    String page = errorPage.get(status);
    if(VerifyUtils.isEmpty(page))
      return getDefaultErrorPage(status, content);
   
    TemplateFactory templateFactory = TemplateView.getTemplateFactory();
    if(templateFactory == null)
      return getDefaultErrorPage(status, content);
   
    com.firefly.template.View v = templateFactory.getView(page);
    if(v == null)
      return getDefaultErrorPage(status, content);
   
    ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
    Model model = new Model() {
View Full Code Here

Examples of com.firefly.template.TemplateFactory

        }
      }};
    FunctionRegistry.add("testFunction2", function2);
   
    // #if #elseif #else
    TemplateFactory t = new TemplateFactory(new File(TestConfig.class.getResource("/page").toURI())).init();
//    System.out.println(t.getConfig().getViewPath());
//    System.out.println(t.getConfig().getCompiledPath());
    View view = t.getView("/testIf.html");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Model model = new ModelMock();
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
    System.out.println("=======================================");
   
    out = new ByteArrayOutputStream();
    model.put("otherAge", 33);
    model.put("user", user);
    model.put("login", true);
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
    System.out.println("=======================================for");
   
    // #for
    model = new ModelMock();
    out = new ByteArrayOutputStream();
    view = t.getView("/testFor.html");
   
    List<User> list = new ArrayList<User>();
    user = new User();
    user.setName("Tom");
    user.setAge(20);
    list.add(user);
   
    user = new User();
    user.setName("小明");
    user.setAge(13);
    list.add(user);
   
    user = new User();
    user.setName("小红");
    user.setAge(20);
    list.add(user);
   
    model.put("users", list);
    model.put("intArr", new int[]{1,2,3,4,5});
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
    System.out.println("=======================================");
   
    // #switch #case #default
    model = new ModelMock();
    out = new ByteArrayOutputStream();
    view = t.getView("/testSwitch.html");
    model.put("stage", 2);
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
    System.out.println("=======================================");
   
    // #set
    model = new ModelMock();
    out = new ByteArrayOutputStream();
    view = t.getView("/testSet.html");
    model.put("name", "迈克");
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
    System.out.println("=======================================");
   
    // #include
    model = new ModelMock();
    out = new ByteArrayOutputStream();
    view = t.getView("/testInclude.html");
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
    System.out.println("=======================================");
   
    // #function
    model = new ModelMock();
    model.put("teststr", "好长好长,好大好大,的一个东东!");
    model.put("testXmlEscape", "<input type=\"text\">测试</input>");
    out = new ByteArrayOutputStream();
    view = t.getView("/testFunction.html");
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
//    FunctionRegistry.MAP.get("").render(model, out, obj)
  }
View Full Code Here

Examples of com.firefly.template.TemplateFactory

        long end = System.currentTimeMillis();
        System.out.println("freemark: " + (end - start) + "ms\t" + (int)(times / (double)(end - start) * 1000) + "tps");
//        System.out.println(new String(ret, "UTF-8"));
       
        // firefly
        final TemplateFactory t = new TemplateFactory(new File(TestConfig.class.getResource("/").toURI())).init();
        FunctionRegistry.add("book_count", new Function() {

      @Override
      public void render(Model model, OutputStream out, Object... obj) throws Throwable {
        Book book = (Book)obj[0];
        out.write(String.valueOf(book.getPrice() * book.getDiscount() / 100).getBytes(t.getConfig().getCharset()));
      }
     
    });
        View view = t.getView("/books.html");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        view.render(model, out);
    out.close();
    start = System.currentTimeMillis();
        for (int i = 0; i < times; i++) {
View Full Code Here

Examples of com.firefly.template.TemplateFactory

      _viewPath = viewPath;
      com.firefly.template.Config config = new com.firefly.template.Config();
      config.setViewPath(viewPath);
      config.setCharset(encoding);
      charset = encoding;
      templateFactory = new TemplateFactory(config).init();
      init = true;
    }
  }
View Full Code Here

Examples of com.firefly.template.TemplateFactory

   * @param args
   */
  public static void main(String[] args) throws Throwable {
    String str = "测试一下页面";
    System.out.println(Arrays.toString(str.getBytes("UTF-8")));
    TemplateFactory t = new TemplateFactory(new File(CharsetDemo.class.getResource("/page").toURI())).init();
    View view = t.getView("/index2.html");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Model model = new ModelMock();
    view.render(model, out);
    out.close();
    System.out.println(out.toString());
View Full Code Here

Examples of com.google.clearsilver.jsilver.interpreter.TemplateFactory

      outputBufferProvider = new InstanceOutputBufferProvider(bufferSize);
    }

    // Loads the template from the resource loader, manipulating the AST as
    // required for correctness.
    TemplateFactory templateFactory = new LoadingTemplateFactory();

    // Applies optimizations to improve performance.
    // These steps are entirely optional, and are not required for correctness.
    templateFactory = setupOptimizerFactory(templateFactory);
View Full Code Here

Examples of com.liferay.faces.util.template.TemplateFactory

  // Private Data Members
  private Template template;

  public WYSIWYGTemplate(boolean minified) throws IOException {
    TemplateFactory templateFactory = (TemplateFactory) FactoryExtensionFinder.getFactory(TemplateFactory.class);
    this.template = templateFactory.getTemplate(this.getClass(), "wysiwyg.js", minified);
  }
View Full Code Here

Examples of com.liferay.faces.util.template.TemplateFactory

  // Private Data Members
  private Template template;

  public PreviewTableTemplate(boolean minified) throws IOException {
    TemplateFactory templateFactory = (TemplateFactory) FactoryExtensionFinder.getFactory(TemplateFactory.class);
    this.template = templateFactory.getTemplate(this.getClass(), "preview-table.html", minified);
  }
View Full Code Here

Examples of com.liferay.faces.util.template.TemplateFactory

  private Template template;

  public ProgressTableTemplate(boolean minified) throws IOException {
    super(minified);

    TemplateFactory templateFactory = (TemplateFactory) FactoryExtensionFinder.getFactory(TemplateFactory.class);
    this.template = templateFactory.getTemplate(this.getClass(), "progress-table.html", minified);
  }
View Full Code Here

Examples of com.sun.grid.cull.template.TemplateFactory

    private File outputFile;


    /** Creates a new instance of CullTemplateConverter */
    public CullTemplateConverter(File buildDir, String classpath, File outputFile, File template, String javaSourceVersion, String javaTargetVersion) {
        fac = new TemplateFactory(buildDir, classpath, javaSourceVersion, javaTargetVersion);
        this.outputFile = outputFile;
        this.templateFile = template;
    }
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.