In ASP.NET MVC I could parse Razor scripts like this:
string template = "It is @DateTime.Now.ToString()";
string result = Razor.Parse(template);
But this static doesn't exist in core.
Also I've read this post, but in my case the view code is a string, so I can't use the find
or get
view methods from the ICompositeViewEngine
.
Any advice on how to get a view string parsed in core?
I've already answered the question Here
Today I've finished with my library that can solve your problem. You can use it out of ASP.NET as it has no dependencies on it
This is how you can use it
string template = "It is @DateTime.Now.ToString()";
string result = new LightRazorEngine().ParseString(template);
More: https://github.com/toddams/RazorLight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With