public void Can_Render_MarkdownPage_with_foreach() { var person = new Person { FirstName = "Demis", LastName = "Bellot", Links = new List<Link> { new Link { Name = "ServiceStack", Href = "http://www.servicestack.net" }, new Link { Name = "AjaxStack", Href = "http://www.ajaxstack.net" }, }, }; var markdownHtml = MarkdownFormat.Instance.Transform(dynamicListPageContent); Console.WriteLine(markdownHtml); var dynamicPage = new MarkdownPage( dynamicListPagePath, "DynamicListTpl", dynamicListPageContent); dynamicPage.Prepare(); Assert.That(dynamicPage.Blocks.Count, Is.EqualTo(9)); var expectedHtml = markdownHtml .Replace("@model.FirstName", person.FirstName) .Replace("@model.LastName", person.LastName); var templateArgs = new Dictionary<string, object> { { "model", person } }; var templateOutput = dynamicPage.RenderToString(templateArgs); Console.WriteLine("Template Output: " + templateOutput); Assert.That(templateOutput, Is.EqualTo(expectedHtml)); }
public void Can_Render_MarkdownPage() { var person = new Person { FirstName = "Demis", LastName = "Bellot" }; var dynamicPage = new MarkdownPage(dynamicPageContent, "DynamicTpl", dynamicListPageContent); dynamicPage.Prepare(); Assert.That(dynamicPage.Blocks.Count, Is.EqualTo(9)); var expectedHtml = MarkdownFormat.Instance.Transform(dynamicListPageContent) .Replace("@model.FirstName", person.FirstName) .Replace("@model.LastName", person.LastName); var templateArgs = new Dictionary<string, object> { { "model", person } }; var templateOutput = dynamicPage.RenderToString(templateArgs); Console.WriteLine("Template Output: " + templateOutput); Assert.That(templateOutput, Is.EqualTo(expectedHtml)); }
public string RenderDynamicPage(MarkdownPage markdownPage, Dictionary<string, object> scopeArgs, bool renderHtml, bool renderTemplate) { scopeArgs = scopeArgs ?? new Dictionary<string, object>(); var htmlPage = markdownPage.RenderToString(scopeArgs, renderHtml); if (!renderTemplate) return htmlPage; var html = RenderInTemplateIfAny( markdownPage, scopeArgs, htmlPage); return html; }
private string RenderDynamicPage(MarkdownPage markdownPage, object model, bool renderHtml, bool renderTemplate) { if (markdownPage == null) throw new InvalidDataException(ErrorPageNotFound.FormatWith(markdownPage.Name)); var scopeArgs = new Dictionary<string, object> { { MarkdownPage.ModelName, model } }; var htmlPage = markdownPage.RenderToString(scopeArgs, renderHtml); if (!renderTemplate) return htmlPage; var html = RenderInTemplateIfAny(markdownPage.TemplatePath, htmlPage); return html; }