Examples of ClassTemplateLoader


Examples of freemarker.cache.ClassTemplateLoader

         try {
             if(templatePath!=null){
                 if (templatePath.startsWith("class://")) {
                     // substring(7) is intentional as we "reuse" the last slash
                     templatePathLoader = new ClassTemplateLoader(getClass(), templatePath.substring(7));
                 } else if (templatePath.startsWith("file://")) {
                     templatePathLoader = new FileTemplateLoader(new File(templatePath.substring(7)));
                 }
             }
         } catch (IOException e) {
View Full Code Here

Examples of freemarker.cache.ClassTemplateLoader

        }
          } else {
            log.warn("template path" + file + " either does not exist or is not a directory");
          }
    }
        loaders.add(new ClassTemplateLoader(this.getClass(),"/")); // the template names are like pojo/Somewhere so have to be a rooted classpathloader
       
        freeMarkerEngine.setTemplateLoader(new MultiTemplateLoader((TemplateLoader[]) loaders.toArray(new TemplateLoader[loaders.size()])));
       
    }
View Full Code Here

Examples of freemarker.cache.ClassTemplateLoader

     * so see {@link ClassTemplateLoader#ClassTemplateLoader(Class, String)} for more details.
     *
     * @see #setTemplateLoader(TemplateLoader)
     */
    public void setClassForTemplateLoading(Class clazz, String pathPrefix) {
        setTemplateLoader(new ClassTemplateLoader(clazz, pathPrefix));
    }
View Full Code Here

Examples of freemarker.cache.ClassTemplateLoader

     */
    protected TemplateLoader createTemplateLoader(String templatePath) throws IOException
    {
        if (templatePath.startsWith("class://")) {
            // substring(7) is intentional as we "reuse" the last slash
            return new ClassTemplateLoader(getClass(), templatePath.substring(7));
        } else {
            if (templatePath.startsWith("file://")) {
                templatePath = templatePath.substring(7);
                return new FileTemplateLoader(new File(templatePath));
            } else {
View Full Code Here

Examples of net.sf.lapg.templates.api.impl.ClassTemplateLoader

      if (tl != null) {
        loaders.add(tl);
      }
    }
    if (options.isUseDefaultTemplates()) {
      loaders.add(new ClassTemplateLoader(getClass().getClassLoader(), "net/sf/lapg/gen/templates", "utf8"));
    }

    TemplatesFacade env = new TemplatesFacadeExt(new GrammarNavigationFactory(options.getTemplateName()), loaders.toArray(new IBundleLoader[loaders.size()]), notifier);
    EvaluationContext context = new EvaluationContext(map);
    context.setVariable("util", new TemplateStaticMethods());
View Full Code Here

Examples of net.sf.lapg.templates.api.impl.ClassTemplateLoader

public class XmlTest extends TemplateTestCase{

  public void testSelector() {
    XmlNode n = XmlModel.load(" <r><user name='jone'/>go<user name='go'/></r> ");

    TestTemplatesFacade env = new TestTemplatesFacade(new XmlNavigationFactory(), new ClassTemplateLoader(getClass().getClassLoader(), "net/sf/lapg/templates/test/ltp", "utf8"));

    // test 1
    String q = env.executeTemplate("xmltest.xmldo", new EvaluationContext(n), null, null);
    Assert.assertEquals("jone\ngo\n", q);
    env.assertEmptyErrors();
View Full Code Here

Examples of net.sf.lapg.templates.api.impl.ClassTemplateLoader

  // loop.ltp
  public void testLoops() {
    Hashtable<String,String[]> h = new Hashtable<String,String[]>();
    h.put("list", new String[] { "a", "b" });

    TemplatesFacade env = new TestTemplatesFacade(new DefaultNavigationFactory(), new ClassTemplateLoader(getClass().getClassLoader(), TEMPLATES_LOCATION, TEMPLATES_CHARSET));

    // test 1
    String q = env.executeTemplate("loop.loop1", new EvaluationContext(h), null, null);
    Assert.assertEquals("Hmm: \n\n0: a\n1: b\n\n", q);
View Full Code Here

Examples of net.sf.lapg.templates.api.impl.ClassTemplateLoader

    Assert.assertEquals("\nHmm: \n\n\n", q);
  }

  // eval.ltp
  public void testEval() {
    TemplatesFacade env = new TestTemplatesFacade(new DefaultNavigationFactory(), new ClassTemplateLoader(getClass().getClassLoader(), TEMPLATES_LOCATION, TEMPLATES_CHARSET));

    // test 1
    String q = env.executeTemplate("eval.eval1", null, null, null);
    Assert.assertEquals("w1 is bad\nw2 is bad\nt4 is bad\n", q);
  }
View Full Code Here

Examples of net.sf.lapg.templates.api.impl.ClassTemplateLoader

    Assert.assertEquals("w1 is bad\nw2 is bad\nt4 is bad\n", q);
  }

  // query.ltp
  public void testQuery() {
    TemplatesFacade env = new TestTemplatesFacade(new DefaultNavigationFactory(), new ClassTemplateLoader(getClass().getClassLoader(), TEMPLATES_LOCATION, TEMPLATES_CHARSET));

    // test 1
    String q = env.executeTemplate("query.a", new EvaluationContext(new Object()), null, null);
    Assert.assertEquals("\n123\n", q);
  }
View Full Code Here

Examples of net.sf.lapg.templates.api.impl.ClassTemplateLoader

    Assert.assertEquals("\n123\n", q);
  }

  // dollar.ltp
  public void testDollar() {
    TestTemplatesFacade env = new TestTemplatesFacade(new DefaultNavigationFactory(), new ClassTemplateLoader(getClass().getClassLoader(), TEMPLATES_LOCATION, TEMPLATES_CHARSET));

    // test 1
    String q = env.executeTemplate("dollar.testdollar", null, null, null);
    Assert.assertEquals("$ is dollar\n", q);
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.