Allow empty partial-block#606
Conversation
Head branch was pushed to by a user without write access
e89ad99 to
63c6683
Compare
|
@rexm I rebased on the current master, which disabled the auto-merge you set |
CI failure diagnosisThe The 0-body case previously returned Fix: keep var fallback = _body.Count switch
{
0 => (Expression)null, // ← null, not Expression.Empty()
1 => _body[0],
_ => Expression.Block(_body)
}; |
While it is true, that the test of #519 fails, this is not the fix. If you replaced |
I authored a partial-template with optional block-includes and happened to write
{{#>mail}}{{/mail}}for the test-mail, as I did not need to adjust the optionals. This led to an exception similar to the one below:Being new to Handlebars.Net it took me a while to understand what really was wrong. I no know, that I can change the template to
{{>mail}}, but the exception isn't really helpful and I don't know why it shouldn't just render. So this pull-request allows block-includes with empty blocks.On a side-note
{{#>mail}}{{/mail}}renders, if nomail-partial is present, while{{>mail}}throws an exception, if noMissingPartialTemplateHandleris registered. While not necessary for my use-case it may even be nice to have a syntax, that allows for optional partials out-of-the-box.