Ejemplo n.º 1
0
        public void Simple_Layout_Example()
        {
            var websiteTemplate =
                @"<!DOCTYPE html>
<html>
    <head>
        <title>Simple Site</title>
    </head>
    <body>
    
        <div id=""header"">
            <a href=""/"">Home</a>
            <a href=""/About"">About</a>
        </div>
        
        <div id=""body"">
            <!--@Body-->
        </div>
    </body>
</html>".NormalizeNewLines();

            var pageTemplate =
                @"@Layout websiteTemplate

# About this Site

This is some content that will make up the ""about"" 
page of our web-site. We'll use this in conjunction
with a layout template. The content you are seeing here
comes from ^^^websiteTemplate.

And obviously I can have code in here too. Here is the
current date/year: @DateTime.Now.Year
".NormalizeNewLines();

            var expectedHtml = @"<!DOCTYPE html>
<html>
    <head>
        <title>Simple Site</title>
    </head>
    <body>
    
        <div id=""header"">
            <a href=""/"">Home</a>
            <a href=""/About"">About</a>
        </div>
        
        <div id=""body"">
            <h1>About this Site</h1>
<p>This is some content that will make up the &quot;about&quot; 
page of our web-site. We'll use this in conjunction
with a layout template. The content you are seeing here
comes from ^^^websiteTemplate.</p>
<p>And obviously I can have code in here too. Here is the
current date/year: 2021</p>

        </div>
    </body>
</html>".NormalizeNewLines();


            markdownFormat.AddFileAndPage(
                new MarkdownPage(markdownFormat, @"C:\path\to\page-tpl", PageName, pageTemplate));

            markdownFormat.AddFileAndTemplate(@"websiteTemplate", websiteTemplate);

            var html = markdownFormat.RenderDynamicPageHtml(PageName);

            Console.WriteLine(html);
            Assert.That(html, Is.EqualTo(expectedHtml));
        }