ITeye博客

Light-Commons 加入 Template Facade

jasongreen · 2008-06-18 00:33 · light-commons · 企业架构 · Java · freemarker · ASP · JSP · commontemplate · Markdown

template 个人认为是web的精髓,如今看来JSP,ASP也都可列为模板范畴,但*SP无疑是失败的,个人观点。

模板+数据=输出,所有模板引擎都是如此,light-commons 试图为流行模板提供统一的接口。目前实现了Freemarker,Commontemplate的Facade.

对于代码开发而言,所需要关心的只有Template,TemplateFactory,剩下的就是了解模板语言。


public interface Template {
	String render(Object rootMap);

	void render(Object rootMap, Writer writer);
}

public interface TemplateFactory {
	Template compile(String name,String source) throws IOException;

	Template getTemplate(String location,String encoding) throws Exception;
	
	Template getTemplate(String location,Locale local,String encoding) throws Exception;
	
	Template getTemplate(String name,InputStream inputStream, String encoding) throws IOException;

	Template getTemplate(Resource resource, String encoding) throws Exception;
	
	void setResourceLoader(ResourceLoader resourceLoader);
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。