在没有 MVC 的情况下使用 Razor

编程入门 行业动态 更新时间:2024-10-28 06:27:05
本文介绍了在没有 MVC 的情况下使用 Razor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要将模板与数据合并以在运行时创建唯一的字符串.有人建议我看看 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 托管模板引擎-www.west-wind/weblog/posts/864461.aspx
  • GitHub 上的 Razor 引擎 - github/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

    本文发布于:2023-11-16 21:25:08,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1607520.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:情况下   MVC   Razor

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!