All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.personify.iam.frontend.wicket.util.TemplateEngine Maven / Gradle / Ivy

There is a newer version: 1.5.2.RELEASE
Show newest version
package be.personify.iam.frontend.wicket.util;

import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateExceptionHandler;

public class TemplateEngine {
	
	
	private static final String TEMPLATE_NAME = "templateName";
	public static Configuration cfg;
	
	static {
		cfg = new Configuration(Configuration.VERSION_2_3_23);
		//cfg.setDirectoryForTemplateLoading(generationInfo.templateDir);
		cfg.setDefaultEncoding("UTF-8");
		cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
		cfg.setLogTemplateExceptions(false);
	}
	
	public static String process( String content, Map map) throws Exception {
		 Template t = new Template(TEMPLATE_NAME, new StringReader(content), cfg);
		 Writer out = new StringWriter();
		 t.process(map, out);
		 return out.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy