Examples of FileTemplateLoader


Examples of freemarker.cache.FileTemplateLoader

   * The WebappTemplateLoader attempts to resolve templates relative to the
   * web root folder
   */
  protected TemplateLoader getTemplateLoader(ServletContext servletContext) {
    // construct a FileTemplateLoader for the init-param 'TemplatePath'
    FileTemplateLoader templatePathLoader = null;

    String templatePath = servletContext.getInitParameter("TemplatePath");
    if (templatePath == null) {
      templatePath = servletContext.getInitParameter("templatePath");
    }

    if (templatePath != null) {
      try {
        templatePathLoader = new FileTemplateLoader(new File(templatePath));
      } catch (IOException e) {
        logger.error("Invalid template path specified:{} ", e.getMessage(), e);
      }
    }

View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

    for (String path : paths) {
      if (path.startsWith("classpath:")) {
        loaders.add(new BeangleClassTemplateLoader(StringUtils.substringAfter(path, "classpath:")));
      } else if (path.startsWith("file:")) {
        try {
          loaders.add(new FileTemplateLoader(new File(path)));
        } catch (IOException e) {
          throw new RuntimeException("templatePath: " + path + " cannot be accessed", e);
        }
      } else if (path.startsWith("webapp:")) {
        loaders.add(new WebappTemplateLoader(servletContext, StringUtils.substringAfter(path,
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

             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) {
             if (LOG.isErrorEnabled()) {
                LOG.error("Invalid template path specified: #0", e, e.getMessage());
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

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

Examples of freemarker.cache.FileTemplateLoader

       
        for (int i = 0; i < templatePaths.length; i++) {
          File file = new File(templatePaths[i]);
          if(file.exists() && file.isDirectory()) {
            try {
          loaders.add(new FileTemplateLoader(file));
        }
        catch (IOException e) {
          throw new ExporterException("Problems with templatepath " + file, e);
        }
          } else {
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

        if (tl instanceof FileTemplateLoader) {
            String path = ((FileTemplateLoader) tl).baseDir.getCanonicalPath();
            if (path.equals(dir.getCanonicalPath()))
                return;
        }
        setTemplateLoader(new FileTemplateLoader(dir));
    }
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

            // 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 {
                return new WebappTemplateLoader(this.getServletContext(), templatePath);
            }
        }
    }
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

public class TemplateNotFoundMessageTest {

    @Test
    public void testFileTemplateLoader() throws IOException {
        final File baseDir = new File(System.getProperty("user.home"));
        final String errMsg = failWith(new FileTemplateLoader(baseDir));
        showErrorMessage(errMsg);
        assertTrue(errMsg.contains(baseDir.toString()));
        assertTrue(errMsg.contains("FileTemplateLoader"));
    }
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

        try {
            if (servletContext != null) {

                WebappTemplateLoader webappTemplateLoader = new WebappTemplateLoader(servletContext);

                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl, webappTemplateLoader };

            } else {
                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl };
            }
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

        try {
            if (servletContext != null) {

                WebappTemplateLoader webappTemplateLoader = new WebappTemplateLoader(servletContext);

                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl, webappTemplateLoader };

            } else {
                TemplateLoader tl = new FileTemplateLoader(rootFile, true);
                loaders = new TemplateLoader[] { tl };
            }
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
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.