private void WriteHtml(IHtmlWriter html, DebugPage page, int depth)
        {
            if (page.Routes != null && page.Routes.Count > 0)
            {
                html.WriteElementLine("h3", "Page routes");
                foreach (var route in page.Routes)
                {
                    html.WriteElementLine("p", "Route: " + route);
                }
            }

            if (page.Scope != null)
            {
                html.WriteElementLine("p", "Page has a data scope");
                StartIndent(html, true);
                WriteDebugInfo(html, page.Scope, depth - 1);
                EndIndent(html);
            }

            if (page.DataContext != null)
            {
                html.WriteElementLine("p", "Page has a data context");
                StartIndent(html, true);
                WriteDebugInfo(html, page.DataContext, depth - 1);

                var dataContextBuilder = page.DataContext.Instance as IDataContextBuilder;
                if (dataContextBuilder != null)
                {
                    DebugRenderContext debugRenderContext;
                    try
                    {
                        var renderContext = _renderContextFactory.Create((c, f) => { });
                        dataContextBuilder.SetupDataContext(renderContext);
                        debugRenderContext = renderContext.GetDebugInfo <DebugRenderContext>();
                    }
                    catch (Exception ex)
                    {
                        debugRenderContext = null;
                        html.WriteElementLine("p", "Exception thrown when constructing data context tree: " + ex.Message);
                        if (!string.IsNullOrEmpty(ex.StackTrace))
                        {
                            html.WriteOpenTag("pre");
                            html.WriteLine();
                            html.WritePreformatted(ex.StackTrace);
                            html.WriteLine();
                            html.WriteCloseTag("pre");
                            html.WriteLine();
                        }
                    }

                    WriteHtml(html, debugRenderContext, depth - 1);
                }

                EndIndent(html);
            }

            if (page.Layout != null)
            {
                html.WriteElementLine("p", "Page has a layout");
                if (depth != 1)
                {
                    StartIndent(html, true);
                    WriteDebugInfo(html, page.Layout, depth - 1);
                    EndIndent(html);
                }
            }
        }