public static void WriteValue(this Html32TextWriter w, int value)
 {
     w.WriteFullBeginTag("td");
     if (value != 0)
     {
         w.Write(value);
     }
     w.WriteEndTag("td");
 }
 public static void WriteValue(this Html32TextWriter w, string value)
 {
     w.WriteFullBeginTag("td");
     if (!string.IsNullOrEmpty(value))
     {
         w.WriteEncodedText(value);
     }
     w.WriteEndTag("td");
 }
        private static void RenderChildren(Html32TextWriter writer, ContentListDecorator list, IEnumerable <ContentDataItem> items, ContentDataItem current)
        {
            var app       = App.Get();
            var fieldName = list.GetDefaultTitleField().Name;
            var Url       = DNA.Utility.UrlUtility.CreateUrlHelper();

            foreach (var item in items)
            {
                var itemWrapper = app.Wrap(item);
                writer.WriteBeginTag("li");
                var _class        = "d-node";
                var children      = itemWrapper.Children();
                var childrenCount = children.Count();
                if (childrenCount > 0)
                {
                    _class += " d-node-hasChildren";
                }

                //writer.WriteAttribute("class", "d-node d-node-hasChildren");


                var isInPath = false;
                if (current != null && !string.IsNullOrEmpty(current.Path) && !string.IsNullOrEmpty(item.Path) && current.Path.StartsWith(item.Path))
                {
                    isInPath = true;
                    if (childrenCount > 0)
                    {
                        writer.WriteAttribute("data-expanded", "true");
                    }
                }
                writer.WriteAttribute("data-id", itemWrapper.ID.ToString());

                if (current != null && itemWrapper.ID.Equals(current.ID))
                {
                    writer.WriteAttribute("data-selected", "true");
                }

                if (itemWrapper.ParentItemID != Guid.Empty)
                {
                    writer.WriteAttribute("data-parentid", itemWrapper.ParentItemID.ToString());
                }

                if (childrenCount > 0)
                {
                    if (!isInPath)
                    {
                        var urlformat = "~/api/contents/items?name={0}&slug={1}&parentId={2}";
                        var popupUrl  = Url.Content(string.Format(urlformat, list.Name, list.Views.Default.Name, itemWrapper.ID.ToString()));
                        writer.WriteAttribute("data-popupurl", popupUrl);
                    }
                }
                writer.WriteAttribute("class", _class);
                writer.Write(Html32TextWriter.TagRightChar);

                writer.WriteBeginTag("a");
                writer.WriteAttribute("href", itemWrapper.UrlComponent);
                writer.Write(Html32TextWriter.TagRightChar);
                writer.Write(itemWrapper.Value(fieldName).Raw);
                writer.WriteEndTag("a");

                if (childrenCount > 0)
                {
                    if (isInPath)
                    {
                        writer.WriteFullBeginTag("ul");
                        RenderChildren(writer, list, children, current);
                        writer.WriteEndTag("ul");
                    }
                }

                writer.WriteEndTag("li");
            }
        }