对字符串使用剃刀引擎 - 没有意见 [英] Using Razor engine on strings - not views
问题描述
我想用剃刀引擎不认为(CSHTML)文件,但对字符串。
我想从内部MVC做到这一点,我已经看到了使用示例
I'd like to use the Razor engine without view (cshtml) files, but on strings. I want to do it from within MVC, I've seen examples that use
new RazorViewEngine().Render
但我不能找到Render方法,它与MVC的老日子吗?
but I can't find the Render method, is it something from the older days of MVC?
我也看到了使用Razor.Parse例子,但我找不到它要么 - 可能缺少引用(?但它应该在那里,如果我使用MVC已经吧)
I've also seen examples that use Razor.Parse, but I can't find it either - probably missing a reference (but it should be there if I'm using MVC already, right?)
它是建议在所有使用剃须刀,如果所有我需要做的是注入3-4参数到HTML字符串?我觉得我有点现在与迷恋的MVC,可能不能变直思考。我打算在内存中缓存HTML串,只是传递的模型从数据库。
Is it advisable at all to use Razor if all I need to do is inject 3-4 parameters into an HTML string? I think I'm a bit infatuated with MVC right now and might not be thinking straight. I'm planning to cache the HTML strings in memory and just pass-in models from DB.
感谢您
推荐答案
您可以看看 RazorEngine
这篇关于对字符串使用剃刀引擎 - 没有意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!