Package freemarker.cache

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


    private TemplateLoader getTemplateLoader(InitParams initParams,
            AppResources resources, String ftlPath) {
       
        if (ftlPath.startsWith(CLASSPATH_PATH_PREFIX)) {
            Class<?> clazz = getFTLPathClass(initParams);
            return new ClassTemplateLoader(clazz,
                    ftlPath.replaceFirst(CLASSPATH_PATH_PREFIX, ""));
        }
       
        return new MojaveTemplateLoader(resources, ftlPath);
    }
View Full Code Here

    public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
        FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
        freeMarkerConfigurer.setConfiguration(new freemarker.template.Configuration() {{
            setTemplateLoader(new MultiTemplateLoader(
                    new TemplateLoader[]{
                            new ClassTemplateLoader(FreeMarkerConfig.class, "/")
                    }
            ));
            setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
            setStrictSyntaxMode(true);
            setWhitespaceStripping(true);
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

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

        model.put("books", books);
       
     // freemark
        StringWriter writer = new StringWriter();
        Configuration configuration = new Configuration();
        configuration.setTemplateLoader(new ClassTemplateLoader(PerformanceTest.class, "/"));
        Template template = configuration.getTemplate("books.ftl");
        template.process(context, writer);
//        byte[] ret = null;
        long start = System.currentTimeMillis();
        for (int i = 0; i < times; i++) {
View Full Code Here

        // Templates are stored in the / directory of the Web app.
        WebappTemplateLoader webloader = new WebappTemplateLoader(servletContext);

        // Templates are stored in the root of the classpath.
        ClassTemplateLoader classLoader = new ClassTemplateLoader(getClass(), "/");
        TemplateLoader[] loaders = new TemplateLoader[] { webloader, classLoader };
        MultiTemplateLoader multiLoader = new MultiTemplateLoader(loaders);

        configuration.setTemplateLoader(multiLoader);
View Full Code Here

    public synchronized Configuration getConfiguraiton() {
        if (configuraiton == null) {
            configuraiton = new Configuration();
            // use class template loader using Spring Resource class and / as root in classpath
            configuraiton.setTemplateLoader(new ClassTemplateLoader(Resource.class, "/"));
        }
        return (Configuration) configuraiton.clone();
    }
View Full Code Here

         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

     *
     * @param servletContext The servlet context.
     */
    public WebappClassTemplateLoader(ServletContext servletContext) {
        webappTemplateLoader = new WebappTemplateLoader(servletContext);
        classTemplateLoader = new ClassTemplateLoader(getClass(), "/");
    }
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.