Whilst creating a custom UnsafeUnescapedLeafTag, context.requireNoBody() always throws even if no body is provided, while context.requireBody() never throws even when no body is provided, rather returning an empty [Syntax].
While looking through the tests I noticed these methods are not tested anywhere and I think simply checking for the array being empty in addition to checking for it being != nil could solve the issue. The other option would be searching where the body of the tag is passed in and setting it to nil if it's an empty array
Describe the bug
Whilst creating a custom
UnsafeUnescapedLeafTag
,context.requireNoBody()
always throws even if no body is provided, whilecontext.requireBody()
never throws even when no body is provided, rather returning an empty[Syntax]
.While looking through the tests I noticed these methods are not tested anywhere and I think simply checking for the array being empty in addition to checking for it being
!= nil
could solve the issue. The other option would be searching where thebody
of the tag is passed in and setting it tonil
if it's an empty arrayTo Reproduce
Create a simple project just using Leaf 4
Create
and
Add the tags to the test project
Adding the first tag to the project
or
This returns
Hello there
, which is just the return type of the tag, while it should be returning{error: true, reason: "Missing body"
Adding the other tag
This returns
{error: true, reason: "Extraneous body"}
The only way to make this error go away is to set the template asWhich is, I think, not that intuitive
Environment
4.76.0
18.6.0
MacOS Ventura 13.0
14.1 (14B47b)