public static UtilCache<String, Template> cachedTemplates = UtilCache.createUtilCache("template.ftl.general", 0, 0, false);
protected static BeansWrapper defaultOfbizWrapper = BeansWrapper.getDefaultInstance();
protected static Configuration defaultOfbizConfig = makeConfiguration(defaultOfbizWrapper);
public static Configuration makeConfiguration(BeansWrapper wrapper) {
Configuration newConfig = new Configuration();
newConfig.setObjectWrapper(wrapper);
newConfig.setSharedVariable("Static", wrapper.getStaticModels());
newConfig.setLocalizedLookup(false);
newConfig.setSharedVariable("StringUtil", new BeanModel(StringUtil.INSTANCE, wrapper));
newConfig.setTemplateLoader(new FlexibleTemplateLoader());
newConfig.setAutoImports(UtilProperties.getProperties("freemarkerImports"));
newConfig.setTemplateExceptionHandler(new FreeMarkerWorker.OFBizTemplateExceptionHandler());
try {
newConfig.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");
newConfig.setSetting("number_format", "0.##########");
} catch (TemplateException e) {
Debug.logError("Unable to set date/time and number formats in FreeMarker: " + e, module);
}
// Transforms properties file set up as key=transform name, property=transform class name
ClassLoader loader = Thread.currentThread().getContextClassLoader();