Search in sources :

Example 1 with ClassTemplateLoader

use of freemarker.cache.ClassTemplateLoader in project spring-framework by spring-projects.

the class FreeMarkerConfigurer method postProcessTemplateLoaders.

/**
	 * This implementation registers an additional ClassTemplateLoader
	 * for the Spring-provided macros, added to the end of the list.
	 */
@Override
protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) {
    templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, ""));
    logger.info("ClassTemplateLoader for Spring macros added to FreeMarker configuration");
}
Also used : ClassTemplateLoader(freemarker.cache.ClassTemplateLoader)

Example 2 with ClassTemplateLoader

use of freemarker.cache.ClassTemplateLoader in project camel by apache.

the class FreemarkerEndpointTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() throws Exception {
            FreemarkerEndpoint endpoint = new FreemarkerEndpoint();
            endpoint.setCamelContext(context);
            endpoint.setResourceUri("org/apache/camel/component/freemarker/example.ftl");
            Configuration configuraiton = new Configuration();
            configuraiton.setTemplateLoader(new ClassTemplateLoader(Resource.class, "/"));
            endpoint.setConfiguration(configuraiton);
            context.addEndpoint("free", endpoint);
            from("direct:a").to("free");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Configuration(freemarker.template.Configuration) ClassTemplateLoader(freemarker.cache.ClassTemplateLoader) Resource(org.springframework.core.io.Resource)

Example 3 with ClassTemplateLoader

use of freemarker.cache.ClassTemplateLoader in project OpenMEAP by OpenMEAP.

the class FreeMarkerTestUtils method createConfiguration.

public static Configuration createConfiguration(Class<?> clazz, String path) {
    Configuration cfg = new Configuration();
    cfg.setTemplateLoader(new ClassTemplateLoader(clazz, path));
    cfg.setObjectWrapper(new DefaultObjectWrapper());
    return cfg;
}
Also used : Configuration(freemarker.template.Configuration) ClassTemplateLoader(freemarker.cache.ClassTemplateLoader) DefaultObjectWrapper(freemarker.template.DefaultObjectWrapper)

Example 4 with ClassTemplateLoader

use of freemarker.cache.ClassTemplateLoader in project spring-framework by spring-projects.

the class FreeMarkerConfigurer method postProcessTemplateLoaders.

/**
	 * This implementation registers an additional ClassTemplateLoader
	 * for the Spring-provided macros, added to the end of the list.
	 */
@Override
protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) {
    templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, ""));
    logger.info("ClassTemplateLoader for Spring macros added to FreeMarker configuration");
}
Also used : ClassTemplateLoader(freemarker.cache.ClassTemplateLoader)

Example 5 with ClassTemplateLoader

use of freemarker.cache.ClassTemplateLoader in project opennms by OpenNMS.

the class ModalInjector method generateModalHtml.

protected static String generateModalHtml(boolean showOnLoad) throws IOException, TemplateException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
    ClassTemplateLoader ctl = new ClassTemplateLoader(ModalInjector.class, "/web");
    cfg.setTemplateLoader(ctl);
    // Load the template
    Template template = cfg.getTemplate("modal.ftl.html");
    // Build out model
    Map<String, Object> data = Maps.newHashMap();
    data.put("showOnLoad", showOnLoad);
    // Render to string
    Writer out = new StringWriter();
    template.process(data, out);
    out.flush();
    return out.toString();
}
Also used : Configuration(freemarker.template.Configuration) StringWriter(java.io.StringWriter) ClassTemplateLoader(freemarker.cache.ClassTemplateLoader) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Template(freemarker.template.Template)

Aggregations

ClassTemplateLoader (freemarker.cache.ClassTemplateLoader)6 Configuration (freemarker.template.Configuration)4 UnexpectedServerException (com.pratilipi.common.exception.UnexpectedServerException)1 FileTemplateLoader (freemarker.cache.FileTemplateLoader)1 MultiTemplateLoader (freemarker.cache.MultiTemplateLoader)1 DefaultObjectWrapper (freemarker.template.DefaultObjectWrapper)1 Template (freemarker.template.Template)1 File (java.io.File)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 Resource (org.springframework.core.io.Resource)1