ASP.NET MVC的Razor视图引擎 [英] ASP.NET MVC Razor view engine

查看:144
本文介绍了ASP.NET MVC的Razor视图引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读有关新的斯科特格思里的博客条目后://weblogs.asp .NET / scottgu /存档/ 2010/07/02 /引入-razor.aspx>剃须刀 ASP.NET MVC的视图引擎和阅读本的问题比较可用的视图引擎。

After reading Scott Guthrie's blog entry about the new Razor view engine for ASP.NET MVC and reading this question comparing the available view engines.

剃刀似乎解决大多数的与默认视图引擎的问题。什么功能差异将使你作为一个开发者一个令人信服的选择吗?缺乏哪些功能,将让你使用它?

Razor seems to address most of the problems with the default view engine. What feature differences would make it a compelling choice for you as a developer? What features are lacking that would keep you from using it?

推荐答案

还有很多,查看发动机除了标记语言。很少有星火的特点是我会想念:

There's much more to view engine except markup language. Few Spark features that I will miss:


  • 使用相同的标记语言编写HTML扩展,而不是C#(宏) - 我看到剃刀也支持这一点,我希望它支持方法/参数覆盖;

  • 自定义标签(写入_Tag.spark到使用<标签/>);

  • 自动生成的变量,如varIsFirst,varIndex等;

  • 特别恩pression形式({}为条件属性,$ {}跳过错误等等?!);

  • 漂亮的主/局部布局的支持,包括在部分指定标记的一部分,应在主只有一次渲染(如脚本包括能力);

  • 您仍然可以拥有的WebForms标记 - 伟大的兼容性和增量升级;

  • 支持同时使用,和''引号里彼此(非常有用)。

我喜欢循环/星火语法IFS更多 - 混合HTML<>和C#{}括号看起来并不太好 - 不过这纯属个人意见

I like Spark syntax for loops/ifs more - mixing HTML <> and C# {} braces doesn't look too nice - but that's purely personal opinion.

有是非常有前途的特点剃须刀,太,例如内联模板。鉴于Spark创始人加入了微软,我觉得有一个希望剃刀写得很好,很实用,并得到广泛支持的视图引擎。当然,我不会重新写了数百我用剃刀星火意见(虽然我没有几十重写我的WebForms观点与星火)。不过,我一定会采取在剃刀一个认真的样子 - 我只是从你的问题发现了这一点,感谢 - 我看他现在看起来很有希望。它不与的WebForms竞争,当然,(任何视图引擎比的WebForms更好),但它看起来像一个新的ASP.NET MVC项目一个不错的选择,如果你还没有投入到另一种视图引擎太多。

There're very promising features in Razor, too, e.g. inline templates. Given that Spark creator was hired by Microsoft, I think there's a hope for Razor to be well written, very useful, and well supported view engine. Of course I won't re-write hundreds of my Spark views with Razor (though I did rewrite dozens of my WebForms views with Spark). But I will surely take a serious look at Razor - I only found this out from your questions, thanks - and what I see now looks promising. It doesn't compete with WebForms, of course (any view engine is better than WebForms), but it looks like a good choice for a new ASP.NET MVC project, if you haven't yet invested into another view engine too much.

这篇关于ASP.NET MVC的Razor视图引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆