protected string RenderNodeBlock(NodeBlock block, HtmlHelper html) { //check if the node exists if (block.Content == null) { return(null); } //set the block model for the view to access WebBlocksUtility.CurrentBlockContent = block.Content; //initialise WebBlocksAPI for the view WebBlocksAPI blockInstanceAPI = new WebBlocksAPI(); blockInstanceAPI.CssClasses = new List <string>(); blockInstanceAPI.BlockElement = ""; blockInstanceAPI.BlockAttributes = new Dictionary <string, string>(); //set up the rendering engine for the view IRenderingEngine renderingEngine = ResolveRenderingEngine(block); //if rendering engine is null then the document doesn't exist anymore if (renderingEngine == null || block.Content == null) { return(""); } string blockIdAttribute = WebBlocksUtility.IsInBuilder ? string.Format(" wbid='{0}'", block.Id) : ""; string blockTemplateAttribute = WebBlocksUtility.IsInBuilder ? string.Format(" templateblock='{0}'", block.IsTemplateBlock.ToString().ToLower()) : ""; string blockDeletedAttribute = WebBlocksUtility.IsInBuilder && block.IsDeleted ? " deletedBlock='deleted' style='display:none;visibilty:hidden;'" : ""; string renderedContent = ""; //render renderedContent = renderingEngine.Render(html); List <string> CssClasses = blockInstanceAPI.CssClasses; string blockElement = blockInstanceAPI.BlockElement ?? "div"; blockElement = blockElement != "" ? blockElement : "div"; Dictionary <string, string> blockAttributeDictionary = blockInstanceAPI.BlockAttributes; string blockAttributes = string.Join(" ", blockAttributeDictionary.Keys.Select(c => c + "='" + blockAttributeDictionary[c] + "'")); string blockClass = string.Format("{0}{1}{0}{2}{3}{4}", block.Class.Length > 0 ? " " : "", block.Class, WebBlocksUtility.CurrentBlockContent.GetPropertyValue("cssClasses"), CssClasses.Any() ? " " : "", String.Join(" ", CssClasses)); blockClass = WebBlocksUtility.IsInBuilder ? "block " + blockClass : blockClass; renderedContent = string.Format("<{0} class='{1}'{2}{3}{4}{5}>{6}</{0}>", blockElement, blockClass, blockIdAttribute, blockTemplateAttribute, blockDeletedAttribute, blockAttributes, renderedContent); return(renderedContent); }