private static void AssertRenderingResult <T>(Action <string, string> assertion, T value) { var text = new LiteralText("b"); var inverted = new InvertedBlock("a", text); using (var writer = new StringWriter()) { var context = new RenderContext(null, new { a = value }, writer, null, Options.Defaults()); inverted.Render(context); assertion(text.Text, writer.GetStringBuilder().ToString()); } }
public void Visit(InvertedBlock invertedBlock) { parts.Add(context.GetInnerExpressions(invertedBlock.Name, value => { // the logic here is really confusing, but since GetInnerExpressions does // the truthiness check, it is basically the same as Block.Compile var visitor = new CompilePartVisitor(context); visitor.Visit((Section)invertedBlock); var expression = visitor.Result(); return(expression); }, invert: true)); }
public void Visit(InvertedBlock invertedBlock) { parts.Add(context.GetInnerExpressions(invertedBlock.Name, value => { // the logic here is really confusing, but since GetInnerExpressions does // the truthiness check, it is basically the same as Block.Compile var visitor = new CompilePartVisitor(context); visitor.Visit((Section)invertedBlock); var expression = visitor.Result(); return expression; }, invert: true)); }
public void It_has_a_useful_ToString_method() { var a = new InvertedBlock("a"); Assert.AreEqual("InvertedBlock(\"a\")", a.ToString()); }