public void Stencil_GetContents_handles_block_with_posttitles() { const string template = "{Posts}.{PostTitle}.{/Posts}"; var stream = template.ToStream(); var stencil = _mimeo.CreateStencil("newtemplate", stream); stream.Dispose(); var blog = new BlogTemplate { Posts = new List <BlogPost> { new BlogPost { PostTitle = "1" }, new BlogPost { PostTitle = "2" }, new BlogPost { PostTitle = "3" } } }; var result = _mimeo.Render("newtemplate", blog); result.ShouldEqual(".1..2..3."); }
public void Stencil_GetContents_handles_block_with_nested_blocks_and_simple_replacements() { const string template = "{Posts}{PostTitle} {Comments}...{CommentText} {/Comments}{/Posts}"; var stream = template.ToStream(); var stencil = _mimeo.CreateStencil("newtemplate", stream); stream.Dispose(); var blog = new BlogTemplate { Posts = new List <BlogPost> { new BlogPost { PostTitle = "1", Comments = new List <Comment> { new Comment { Text = "hi" } } }, new BlogPost { PostTitle = "2" }, new BlogPost { PostTitle = "3" } } }; var result = _mimeo.Render("newtemplate", blog); result.ShouldEqual("1 ...hi 2 3 "); }
public void Stencil_GetContents_handles_block_with_simple_replacement() { const string template = "{Post}{PostTitle}{/Post}"; var stream = template.ToStream(); var stencil = _mimeo.CreateStencil("newtemplate", stream); stream.Dispose(); var blog = new BlogTemplate { Post = new BlogPost { PostTitle = "asdf" } }; var result = _mimeo.Render("newtemplate", blog); result.ShouldEqual("asdf"); }
public void Stencil_GetContents_handles_block() { const string template = "{Posts}.{/Posts}"; var stream = template.ToStream(); _mimeo.CreateStencil("newtemplate", stream); stream.Dispose(); var blog = new BlogTemplate { Posts = new List <BlogPost> { new BlogPost(), new BlogPost(), new BlogPost() } }; var result = _mimeo.Render("newtemplate", blog); result.ShouldEqual("..."); }