在ASP.NET MVC中,我可以解析Razor脚本,如下所示:

string template = "It is @DateTime.Now.ToString()";
string result = Razor.Parse(template);

但是内核中不存在此静态变量。

另外,我已经阅读了post,但是在我的情况下,查看代码是字符串,因此无法使用findgetICompositeViewEngine查看方法。

关于如何在核心中解析 View 字符串的任何建议?

最佳答案

我已经回答了Here问题



这就是你可以使用它的方式

string template = "It is @DateTime.Now.ToString()";
string result = new LightRazorEngine().ParseString(template);

更多:https://github.com/toddams/RazorLight

10-06 13:38
查看更多