Render string containing razor-code in view

Viewed 4220

Thinking of CMS use cases here. Imagine a view like this:

// /Home/Index.cshtml
@model object
@{
  var str = "My <b>CMS</b> content with razor code: @Html.ActionLink(\"Click\", \"Home\")"
}
@Html.MyCustomRazorStringRenderer(Model)

Expected output:

My <b>CMS</b> content with razor code: <a href="/Home/Click">Click</a>

What does MyCustomRazorStringRenderer look like? It must somehow do sth. like creating/using the ViewContext and render it (like here: Render a view as a string) but I can't quite get my head around it.

2 Answers
Related