public void ShouldReportAndErrorOnEmptyTags() { var parser = new CustomParser(); parser.RegisterEmptyTag("hello", (w, e, c) => { w.Write("Hello World"); return(Statement.Normal()); }); Assert.Throws <ParseException>(() => parser.Parse("{% hello foo %}")); }
public void ShouldRenderEmptyBlocks() { var parser = new CustomParser(); parser.RegisterEmptyBlock("hello", static (s, w, e, c) => { w.Write("Hello World"); return(s.RenderStatementsAsync(w, e, c)); }); var template = parser.Parse("{% hello %} hi {%- endhello %}"); var result = template.Render(); Assert.Equal("Hello World hi", result); }
public void ShouldRenderEmptyTags() { var parser = new CustomParser(); parser.RegisterEmptyTag("hello", (w, e, c) => { w.Write("Hello World"); return(Statement.Normal()); }); var template = parser.Parse("{% hello %}"); var result = template.Render(); Assert.Equal("Hello World", result); }
public void ShouldRenderIdentifierBlocks() { var parser = new CustomParser(); parser.RegisterIdentifierBlock("hello", (i, s, w, e, c) => { w.Write("Hello "); w.Write(i); return(s.RenderStatementsAsync(w, e, c)); }); var template = parser.Parse("{% hello test %} hi {%- endhello %}"); var result = template.Render(); Assert.Equal("Hello test hi", result); }
public void ShouldRenderIdentifierTags() { var parser = new CustomParser(); parser.RegisterIdentifierTag("hello", (s, w, e, c) => { w.Write("Hello "); w.Write(s); return(Statement.Normal()); }); var template = parser.Parse("{% hello test %}"); var result = template.Render(); Assert.Equal("Hello test", result); }