Boa*_*ler 8 c# asp.net-mvc razor razorengine asp.net-core
在ASP.NET MVC中,我可以像这样解析Razor脚本:
string template = "It is @DateTime.Now.ToString()";
string result = Razor.Parse(template);
Run Code Online (Sandbox Code Playgroud)
但是核心中不存在这种静态.
我也读过这篇文章,但在我看来,视图代码是一个字符串,所以我不能使用find
或者get
查看方法ICompositeViewEngine
.
关于如何在核心中解析视图字符串的任何建议?
我已经在这里回答了这个问题
今天我已经完成了我的图书馆,可以解决你的问题。您可以在 ASP.NET 之外使用它,因为它不依赖它
这是你可以使用它的方式
string template = "It is @DateTime.Now.ToString()";
string result = new LightRazorEngine().ParseString(template);
Run Code Online (Sandbox Code Playgroud)
更多:https : //github.com/toddams/RazorLight
归档时间: |
|
查看次数: |
4184 次 |
最近记录: |