cxzhq2002的杂记

cxzhq2002的杂记

RazorEngine

http://razorengine.codeplex.com/

 

 

RazorEngine has been moved to Github

http://github.com/Antaris/RazorEngine

Update - An early look at RazorEngine v3
New blog post - http://www.fidelitydesign.net/?p=473

Project Description
A templating engine built upon Microsoft's Razor parsing technology. The RazorEngine allows you to use Razor syntax to build robust templates. Currently we have integrated the vanilla Html + Code support, but we hope to support other markup languages in future.

Using the templating engine couldn't be easier, using a simple syntax, we can do the following:

  string template = "Hello @Model.Name! Welcome to Razor!";
  string result = Razor.Parse(template, new { Name = "World" });


The templating engine supports strict and anonymous types, as well as customised base templates, for instance:

  Razor.SetTemplateBase(typeof(HtmlTemplateBase<>));
  
  string template = 
  @"<html>
      <head>
        <title>Hello @Model.Name</title>
      </head>
      <body>
        Email: @Html.TextBoxFor(m => m.Email)
      </body>
    </html>";
    
  var model = new PageModel { Name = "World", Email = "someone@somewhere.com" };
  string result = Razor.Parse(template, model);

NuGet Distribution

The Razor Templating Engine is available through Nuget (http://nuget.codeplex.com/) in Visual Studio. Simply search for RazorEngine in the package manager, or:

    Install-Package RazorEngine

Support Us

Donations are always welcome and very appreciated :-), please send donations via Paypal


Hope you enjoy, feedback is welcome!

 

阅读更多
上一篇企业应用:一个够用的、通用的状态机(管理实体的业务状态)
下一篇用动态语言编写程序,命名更重要
想对作者说点什么? 我来说一句

RazorEngine3.6.1最新版本 Razor引擎

2015年03月17日 276KB 下载

没有更多推荐了,返回首页

关闭
关闭