private void ConfigureMimeographs() { _mimeographs = new Mimeographs(); var blogTemplateMimeo = new Mimeograph <BlogTemplate>(b => { b.Tokenize(p => p.BlogTitle, "{BlogTitle}"); b.Tokenize(p => p.PageTitle, "{PageTitle}"); b.Tokenize(p => p.JavaScriptIncludes, "{JavaScriptIncludes}"); b.Interpolate("{ContentPage('", ".*", "')}", data => data.ToString()); b.TokenizeIf(p => p.Post, "{Post}", p => p.Post != null, block => { block.Tokenize(p => p.PostTitle, "{PostTitle}"); block.Tokenize(p => p.PostDescription, "{PostDescription}"); block.Tokenize(p => p.PostBody, "{PostBody}"); block.Block(p => p.Comments, "{Comments}", ctx => { ctx.Tokenize(p => p.Text, "{CommentText}"); }).EndsWith("{/Comments}"); }).EndsWith("{/Post}"); b.Block(p => p.Posts, "{Posts}", block => { block.Tokenize(p => p.PostTitle, "{PostTitle}"); block.Tokenize(p => p.PostDescription, "{PostDescription}"); block.Tokenize(p => p.PostBody, "{PostBody}"); block.Block(p => p.Comments, "{Comments}", comments => { comments.Tokenize(c => c.Author, "{Author}"); comments.Tokenize(c => c.Email, "{Email}"); comments.Tokenize(c => c.Text, "{CommentText}"); }).EndsWith("{/Comments}"); }).EndsWith("{/Posts}"); }); _mimeographs.Add(blogTemplateMimeo); }
public void TokenBuilder_does_not_use_skipped_formatters() { var mimeograph = new Mimeographs(); var builder = new BlogTemplateTokenBuilder(); builder.Configure(); mimeograph.Add(new Mimeograph <BlogTemplate>(builder)); mimeograph.CreateStencil <BlogTemplate>("blah", "{Id}....{SecondBlogTitle} asdf"); var result = mimeograph.Render("blah", new BlogTemplate { Id = 3, BlogTitle = "hi" }); result.ShouldEqual("3....hi asdf"); }
public void TokenBuilder_uses_value_formatters_properly_and_not_on_regular_text_in_template() { var mimeograph = new Mimeographs(); var builder = new BlogTemplateTokenBuilder(); builder.Configure(); mimeograph.Add(new Mimeograph <BlogTemplate>(builder)); mimeograph.CreateStencil <BlogTemplate>("blah", "{Id}....{BlogTitle}asdf"); var result = mimeograph.Render("blah", new BlogTemplate { Id = 3, BlogTitle = "hi" }); result.ShouldEqual("3....HIasdf"); }
public void TokenBuilder_with_value_formatter_for_int_uses_value_formatter() { var mimeograph = new Mimeographs(); var builder = new BlogTemplateTokenBuilder(); builder.Configure(); mimeograph.Add(new Mimeograph <BlogTemplate>(builder)); mimeograph.CreateStencil <BlogTemplate>("blah", "{Id}"); var result = mimeograph.Render("blah", new BlogTemplate { Id = 3 }); result.ShouldEqual("3"); }
public void TokenBuilder_with_value_formatters_uses_value_formatters() { var mimeograph = new Mimeographs(); var builder = new BlogTemplateTokenBuilder(); builder.Configure(); mimeograph.Add(new Mimeograph <BlogTemplate>(builder)); const string template = "{BlogTitle}"; mimeograph.CreateStencil <BlogTemplate>("blah", template); var result = mimeograph.Render("blah", new BlogTemplate { BlogTitle = "Hi" }); result.ShouldEqual("HI"); }