Examples of FileTemplateLoader


Examples of freemarker.cache.FileTemplateLoader

  public SmartTemplateLoader(File baseDirectory)
  {
    ValidationUtils.assertNotNull(baseDirectory, "baseDirectory cannot be null");
   
    try {
      fileLoader = new FileTemplateLoader(baseDirectory);
    }
    catch (IOException e) {
      throw new EmailServiceConfigException(e);
    }
  }
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

        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

Examples of freemarker.cache.FileTemplateLoader

     * <p/>
     * 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) {
                LOG.error("Invalid template path specified: " + e.getMessage(), e);
            }
        }

View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

         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

Examples of freemarker.cache.FileTemplateLoader

    public static Configuration newFreeMarkerConfiguration(List<File> templateRootDirs,String defaultEncoding,String templateName) throws IOException {
        Configuration conf = new Configuration();
     
      FileTemplateLoader[] templateLoaders = new FileTemplateLoader[templateRootDirs.size()];
      for(int i = 0; i < templateRootDirs.size(); i++) {
        templateLoaders[i] = new FileTemplateLoader((File)templateRootDirs.get(i));
      }
      MultiTemplateLoader multiTemplateLoader = new MultiTemplateLoader(templateLoaders);
     
      conf.setTemplateLoader(multiTemplateLoader);
      conf.setNumberFormat("###############");
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

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

Examples of freemarker.cache.FileTemplateLoader

                if (servletContext != null) {
                    loaders.add(new WebappTemplateLoader(servletContext));
                }
                loaders.add(new ClassTemplateLoader(FreemarkerViewProcessor.class, "/"));
                try {
                    loaders.add(new FileTemplateLoader(new File("/")));
                } catch (IOException e) {
                    // NOOP
                }

                // Create Factory.
View Full Code Here

Examples of freemarker.cache.FileTemplateLoader

        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(URI.create(templatePath)));
             }
         } catch (IOException e) {
             LOG.error("Invalid template path specified: " + e.getMessage(), e);
         }
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

    final IPathFinder pathFinder = Activator.getDefault().getPathFinder();
    if(pathFinder == null)
      throw new IllegalStateException("Cannot find templates to render because path finder service is not available");
    final File templateDirectory = new File(pathFinder.getDataDirectory(), "templates");
    try {
      return new FileTemplateLoader(templateDirectory);
    } catch (IOException e) {
      logger.log(Level.WARNING, "Failed to open template directory: "+ e.getMessage());
      return null;
    }
   
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.