use of freemarker.cache.ClassTemplateLoader in project pratilipi by Pratilipi.
the class FreeMarkerUtil method getConfiguration.
private static Configuration getConfiguration() throws UnexpectedServerException {
if (cfg == null) {
FileTemplateLoader ftl;
try {
ftl = new FileTemplateLoader(new File("."));
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to set template directory.", e);
throw new UnexpectedServerException();
}
ClassTemplateLoader ctl = new ClassTemplateLoader(FreeMarkerUtil.class.getClassLoader(), "");
MultiTemplateLoader mtl = new MultiTemplateLoader(new TemplateLoader[] { ftl, ctl });
cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setTemplateLoader(mtl);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
}
return cfg;
}
Aggregations