在没有 MVC 的情况下使用 Razor [英] Using Razor without MVC
问题描述
我需要将模板与数据合并以在运行时创建唯一的字符串.有人建议我看看 Razor ASP.NET MVC 3 中的模板视图引擎.看起来不错,但我需要在 MVC 视图创建之外使用它.
I need to merge templates with data to create unique strings at runtime. It was suggested that I look at the Razor templating view engine that comes in ASP.NET MVC 3. Looks great, but I need to use it outside of MVC view creation.
我知道我可以直接使用核心 Razor 引擎,但我也发现了一些可以更轻松地直接使用 Razor 的项目.喜欢:
I know I can use the core Razor engine directly, but I've also found a couple of projects that make using Razor directly easier. Like:
- Rick Strahl 的 Razor 托管模板引擎-http://www.west-wind.com/weblog/posts/864461.aspx
- GitHub 上的 Razor 引擎 - https://github.com/Antaris/RazorEngine
是否有人对在 MVC 之外使用 Razor 作为独立模板引擎有任何指导?这些包装项目有什么经验吗?我应该研究其他 Razor 托管实现吗?
Does anyone have any guidance on using Razor outside of MVC as a standalone template engine? Any experience with these wrapper projects? are there other Razor hosting implementations I should look into?
推荐答案
你可以看看 以下博客文章 说明了如何使用 Razor 视图引擎将模板呈现为字符串.
You may take a look at the following blog post which illustrates how you could use the Razor view engine to render a template to a string.
这篇关于在没有 MVC 的情况下使用 Razor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!