Package org.springmodules.template

Examples of org.springmodules.template.Template.generate()


   
    public String render() {
        Template template = this.templateResolver.resolve(this.templateName, this.characterEncoding, this.locale);
        StringWriter writer = new StringWriter();
       
        template.generate(writer, this.templateModel);
       
        return writer.toString();
    }

    /**
 
View Full Code Here


     * @return The resolved email.
     */
    protected Email resolveEmail(String name, Map model, Locale locale) {
        StringWriter writer = new StringWriter();
        Template template = templateResolver.resolve(name, getEncoding(), locale);
        template.generate(writer, model);

        if (logger.isDebugEnabled()) {
            logger.debug("The generated email descriptor for '" + name + "' is:\n" + writer.toString());
        }

View Full Code Here

     * @return The resolved email.
     */
    protected Email resolveEmail(String name, Map model) {
        StringWriter writer = new StringWriter();
        Template template = templateResolver.resolve(name, getEncoding());
        template.generate(writer, model);
        return emailParser.parse(new StringResource(writer.toString()));
    }

    /**
     * Called by the Spring application context after this object has been wired with its dependencies. This method
View Full Code Here

        Resource resource = new StringResource("Hello ${name}");
        Template template = engine.createTemplate(resource, encoding);

        Map model = new HashMap();
        model.put("name", "Lian");
        assertEquals("Hello Lian", template.generate(model));
    }

    /**
     * Test disabled due to not being aware of localisation. I.e. the test fails when run in New Zealand.
     */
 
View Full Code Here

        loaderControl.replay();

        Template template = engine.createTemplate(resource, encoding);

        assertEquals("Hello", template.generate(new HashMap()));
        loaderControl.verify();
    }

    public void testCreateConfiguration() throws Exception {
View Full Code Here

        Template template = engine.createTemplate(resource, encoding);

        Map model = new HashMap();
        model.put("name", "Daan");

        assertEquals("Hello Daan", template.generate(model));
    }

    public void testCreateTemplate_WithInclude() throws Exception {
        String encoding = "UTF-8";
View Full Code Here

        loaderControl.replay();

        Template template = engine.createTemplate(resource, encoding);

        assertEquals("Hello", template.generate(new HashMap()));
        loaderControl.verify();
    }


    public void testPerformance() throws Exception {
View Full Code Here

        long sum = 0;

        for (int i=0; i<100; i++) {
            StopWatch sw = new StopWatch();
            sw.start();
            template.generate(model);
            sw.stop();
            sum += sw.getTotalTimeMillis();
        }

        System.out.println("took average of " + ((double)sum)/100 + " millis");
View Full Code Here

        loaderControl.replay();

        Template template = engine.createTemplate(resource, encoding);

        assertEquals("Hello", template.generate(new HashMap()));
        loaderControl.verify();
    }

    public void testCreateConfiguration() throws Exception {
View Full Code Here

        Template template = engine.createTemplate(resource);
       
        StringWriter writer = new StringWriter();
        Map model = new HashMap();
        model.put("name", "Lian");
        template.generate(writer, model);

        assertEquals("Hello Lian", writer.toString());
    }
}
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.