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

org.onetwo.common.spring.ftl.Ftls Maven / Gradle / Ivy

package org.onetwo.common.spring.ftl;

import java.util.Map;

import org.onetwo.common.spring.ftl.StringFreemarkerTemplateConfigurer.StringTemplate;

/**
 * @author weishao zeng
 * 
*/ public abstract class Ftls { static public TemplateParser createParser(Map templates) { StringFreemarkerTemplateConfigurer freemarkerTemplateConfigurer = new StringFreemarkerTemplateConfigurer(); templates.forEach((name, template) -> { freemarkerTemplateConfigurer.putTemplate(name, template); }); freemarkerTemplateConfigurer.initialize(); TemplateParser parser = new DefaultTemplateParser(freemarkerTemplateConfigurer); return parser; } static public TemplateParser createStringParser(Map templates) { StringFreemarkerTemplateConfigurer freemarkerTemplateConfigurer = new StringFreemarkerTemplateConfigurer(); templates.forEach((name, template) -> { freemarkerTemplateConfigurer.putTemplate(name, template); }); freemarkerTemplateConfigurer.initialize(); TemplateParser parser = new DefaultTemplateParser(freemarkerTemplateConfigurer); return parser; } /**** * 快速创建一个基于freemarker的模板解释器 * @author weishao zeng * @param templateProvider * @return */ static public TemplateParser createDynamicParser(StringTemplateProvider templateProvider) { DynamicStringFreemarkerTemplateConfigurer freemarkerTemplateConfigurer = new DynamicStringFreemarkerTemplateConfigurer(templateProvider); freemarkerTemplateConfigurer.initialize(); TemplateParser parser = new DefaultTemplateParser(freemarkerTemplateConfigurer); return parser; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy