diff --git a/Fluid.Tests/Extensibility/ExtensibilityTests.cs b/Fluid.Tests/Extensibility/ExtensibilityTests.cs index 52a8a33b..6f53eebb 100644 --- a/Fluid.Tests/Extensibility/ExtensibilityTests.cs +++ b/Fluid.Tests/Extensibility/ExtensibilityTests.cs @@ -1,5 +1,6 @@ using Fluid.Ast; using Parlot.Fluent; +using System; using Xunit; namespace Fluid.Tests.Extensibility @@ -24,6 +25,21 @@ public void ShouldRenderEmptyTags() Assert.Equal("Hello World", result); } + [Fact] + public void ShouldReportAndErrorOnEmptyTags() + { + var parser = new CustomParser(); + + parser.RegisterEmptyTag("hello", (w, e, c) => + { + w.Write("Hello World"); + + return Statement.Normal(); + }); + + Assert.Throws(() => parser.Parse("{% hello foo %}")); + } + [Fact] public void ShouldRenderIdentifierTags() { diff --git a/Fluid/FluidParser.cs b/Fluid/FluidParser.cs index 527544c8..4f3e0ac5 100644 --- a/Fluid/FluidParser.cs +++ b/Fluid/FluidParser.cs @@ -502,7 +502,7 @@ public void RegisterParserBlock(string tagName, Parser parser, Func(x => new ParserBlockStatement(x.Item1, x.Item2, render)) - .ElseError($"Invalid 'tagName' tag") + .ElseError($"Invalid {tagName} tag") ; } @@ -513,7 +513,7 @@ public void RegisterParserTag(string tagName, Parser parser, Func> render) { - RegisteredTags[tagName] = TagEnd.Then(x => new EmptyTagStatement(render)); + RegisteredTags[tagName] = TagEnd.Then(x => new EmptyTagStatement(render)).ElseError($"Unexpected arguments in {tagName} tag"); } public void RegisterEmptyBlock(string tagName, Func, TextWriter, TextEncoder, TemplateContext, ValueTask> render)