template 个人认为是web的精髓,如今看来JSP,ASP也都可列为模板范畴,但*SP无疑是失败的,个人观点。
模板+数据=输出,所有模板引擎都是如此,light-commons 试图为流行模板提供统一的接口。目前实现了Freemarker,Commontemplate的Facade.
对于代码开发而言,所需要关心的只有Template,TemplateFactory,剩下的就是了解模板语言。
模板+数据=输出,所有模板引擎都是如此,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);
}