您的位置:首页 > 其它

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

2013-08-30 22:43 344 查看
这个模板引擎还算不错,对于asp.net的分层架构还是很有帮助的。现在都流行mvc模式。可以研究一下。

1、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。

更多的帮助文档可以看看这里:http://www.codeproject.com/Articles/8141/Ader-Template-Engine#xx2238055xx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐