今天写一篇技术文章,关于TemplateEngine的。

这个模板引擎还算不错,对于asp.net的分层架构仍是颇有帮助的。如今都流行mvc模式。能够研究一下。html

一、foreach,其实重要的就是循环,不少地方都有用到。

<ad:foreach collection="#collection#" var="cust" index="i">
    #cust.lastname#, #cust.firstname# <br />
</ad:foreach>

模板是这样的,那么代码以下架构

 

TemplateManager template = TemplateManager.FromString(Res.c1);

ArrayList list = new ArrayList();
list.Add(new customer("Tom" , "Whatever"));
list.Add(new customer("Henry" , "III"));
list.Add(new customer("Tom" , "Jackson"));
template.SetValue("collection" , list);


string html = template.Process();

这样就生成了html。mvc

更多的帮助文档能够看看这里:http://www.codeproject.com/Articles/8141/Ader-Template-Engine#xx2238055xxasp.net

相关文章
相关标签/搜索