@model dynamic
@using Umbraco.Web.Templates

@functions {
    public static string EditorView(dynamic contentItem)
    {
        string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
        view = view.ToLower().Replace(".html", ".cshtml");
        
        if (!view.Contains("/")) {
            view = "grid/editors/" + view;
        }

        return view;
    }
}
@try
{
    string editor = EditorView(Model);                                                       
    <text>@Html.Partial(editor, (object)Model)</text>
}
catch (Exception ex) { 
<pre>@ex.ToString()</pre>
}