// basic, non-caching version private static Tuple <string, IDictionary <string, object> > Block(HtmlHelper helper, RenderingBlock block, ViewDataDictionary viewData) { // nothing? if (block == null) { return(null); } // get the current block model // BlockModel<TContent> : BlockModel var currentBlockModel = helper.ViewData.Model as BlockModel; if (currentBlockModel == null) { throw new Exception("Model does not inherit from BlockModel."); } var controller = BlockControllerBase.CreateController(helper, block, currentBlockModel.Content, currentBlockModel.CurrentCulture, viewData); var text = controller.RenderInternal(); var meta = controller.Meta; // this is how we get it back... return(Tuple.Create(text, meta)); // we have: // UmbracoViewPage<TModel> : WebViewPage<TModel> // Model is TModel and we know how to map // IPublishedContent, RenderModel, RenderModel<TContent> // UmbracoViewPage : UmbracoViewPage<IPublishedContent> // Model is IPublishedContent // // and deprecating: // UmbracoTemplatePage<TContent> : UmbracoViewPage<RenderModel<TContent>> // Model is RenderModel<TContent> ie Content is TContent // UmbracoTemplatePage : UmbracoViewPage<RenderModel> // Model is RenderModel ie Content is IPublishedContent // UmbracoViewPage<TModel> can map from BlockModel or BlockModel<TContent> // because they inherit from RenderModel, and there is no way it can map // from anything to BlockModel so that's not an issue. // However it does not know how to map BlockModel to BlockModel<TContent> // and that is an issue. So it will fallback to using a TypeConverter, which // we implemented in BlockModelTypeConverter. }
public static string ViewText(ControllerContext context, RenderingBlock block, IPublishedContent content, CultureInfo currentCulture) { var controller = BlockControllerBase.CreateController(context, block, content, currentCulture); return(controller.RenderInternal()); }