10

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?

2

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.