.net模版引擎-DotLiquid使用
2013-05-20 17:49
921 查看
Dotliquid是我新进发现的一个用于.net项目的模板引擎,感觉还不错,使用比较简单,功能非常强大。有兴趣的可以看看https://github.com/formosatek/dotliquid,这里写了2个小例子,大家可以先看看
对应的解析代码如下
对应的代码如下:
{{name.Nick}}
对应的解析代码如下
public class DotLiquidController : Controller { // // GET: /DotLiquid/ [AcceptVerbs(HttpVerbs.Post)] public ActionResult DotLiquidDemo1(string template) { ViewData["template"] = Template.Parse(template).Render(Hash.FromAnonymousObject(new { name =new StudentDrop( new Student() { Nick = "chenlei" } )})); return View(); } public ActionResult DotLiquidDemo1() { return View(); } } public class Student { public string Nick { get; set; } } public class StudentDrop :Drop { private readonly Student student; public string Nick { get {return student.Nick;} } public StudentDrop(Student studentPara) { student = studentPara; } }
{% for item in name %} {{ item.Nick }} {% endfor %}
对应的代码如下:
[AcceptVerbs(HttpVerbs.Post)] public ActionResult DotLiquidDemo1(string template) { ViewData["template"] = Template.Parse(template).Render(Hash.FromAnonymousObject(new { name =new List<StudentDrop>(){ new StudentDrop( new Student() { Nick = "chenlei" } )}})); return View(); } public ActionResult DotLiquidDemo1() { return View(); } } public class Student { public string Nick { get; set; } } public class StudentDrop :Drop { private readonly Student student; public string Nick { get {return student.Nick;} } public StudentDrop(Student studentPara) { student = studentPara; } }
相关文章推荐
- DotLiquid-Asp.net模板引擎
- DotLiquid-Asp.net模板引擎
- DotLiquid-Asp.net模板引擎
- asp.net下的简单的模版引擎实现思路
- doT.js 模板引擎的使用
- 解决DotNetNuke3.0.8菜单不能使用中文的方法
- Asp.net MVC 示例项目"Suteki.Shop"分析之---NVelocity模版引擎
- 基于jQuery的JavaScript模版引擎JsRender使用指南
- php中smarty模版引擎中常用的20个变量操作符及使用方法!
- node+express+ejs使用模版引擎做的一个示例demo
- AderTemplate模版引擎使用分析
- AderTemplate模版引擎使用分析(二)
- ASP.NET Core中使用Razor视图引擎渲染视图为字符串
- C#.net使用DotNetCharting控件生成报表统计图--A
- doT.js 模板引擎的使用
- 使用.NET Reflector 查看Unity引擎里面的DLL文件
- .net使用DotNetCharting控件生成报表统计图总结
- 使用 dotnet watch 开发 ASP.NET Core 应用程序
- 一组优秀的 for .NET Winform UI控件——DotNetMagic最新版本2.3,推荐使用
- AjaxToolKit之Rating控件的使用(http://www.soaspx.com/dotnet/ajax/ajaxtech/ajaxtech_20091021_1219.html)