Package freemarker.cache

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


        }
          } 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

     * 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

     */
    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

        assertTrue(errMsg.contains("FileTemplateLoader"));
    }

    @Test
    public void testClassTemplateLoader() throws IOException {
        final String errMsg = failWith(new ClassTemplateLoader(this.getClass(), "foo/bar"));
        showErrorMessage(errMsg);
        assertTrue(errMsg.contains("ClassTemplateLoader"));
        assertTrue(errMsg.contains("foo/bar"));
    }
View Full Code Here

   
    @Test
    public void testMultiTemplateLoader() throws IOException {
        final String errMsg = failWith(new MultiTemplateLoader(new TemplateLoader[] {
                new WebappTemplateLoader(new MockServletContext(), "WEB-INF/templates"),
                new ClassTemplateLoader(this.getClass(), "foo/bar")
        }));
        showErrorMessage(errMsg);
        assertTrue(errMsg.contains("MultiTemplateLoader"));
        assertTrue(errMsg.contains("WebappTemplateLoader"));
        assertTrue(errMsg.contains("MyApp"));
View Full Code Here

        return STATIC_RESOURCE_PATH;
    }
   
    @Override
    public TemplateLoader getTemplateLoader() {
        return new ClassTemplateLoader(getClass(), TEMPLATE_PATH);
    }
View Full Code Here

        TemplateLoader templatePathLoader = null;

        try {
             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));
             }
         } catch (IOException e) {
             LOG.error("Invalid template path specified: " + e.getMessage(), e);
View Full Code Here

        TemplateLoader templatePathLoader = null;

         try {
             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));
             }
         } catch (IOException e) {
             LOG.error("Invalid template path specified: " + e.getMessage(), e);
View Full Code Here

 
  private TemplateLoader buildTemplateLoader(List<TemplateLoader> loaders){
    try {
      FileTemplateLoader loader1 = new FileTemplateLoader(workingTemplateDir);
      FileTemplateLoader loader2 = new FileTemplateLoader(templateDir);
      ClassTemplateLoader loader3 = new ClassTemplateLoader(RendererImpl.class, "/org/opoo/press/templates");
       
      if(loaders == null){
        loaders = new ArrayList<TemplateLoader>();
      }
      if(loaders != null){
View Full Code Here

TOP

Related Classes of freemarker.cache.ClassTemplateLoader

Copyright © 2018 www.massapicom. 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.