I have a helper called EditableArea which provides a user with a runtime-editable div (via JS). EditableArea helper checks if an editable area (not
Just to expand on the accepted answer, as it took me quite a while to resolve a similar problem and this is the question which popped up. What I really need was a @helper, which would accept razor text, as the template should contain quite some code. I played around for a long while trying to use several versions of type @helper item(Func, which I found on the web, with no success. Therefore I went for an approach like:
namespace project.MvcHtmlHelpers
{
public static class HelperExtensions
{
public static MvcHtmlString RazorToMvcString(this HtmlHelper htmlHelper, Func
and
@project.MvcHtmlHelpers
@helper item(other input, MvcHtmlString content)
{
...other stuff...
@content
}
and use this via
@item(other input, @Html.RazorToMvcString(@this is a test ))
Now I can use the helper template for both Razor input, but I can also drop in partial views, which is handy at some points. As I am no expert there might be better options, but it seems like a flexible approach to me.