Handlebars-Net/Handlebars.Net

Handlebars.Configuration.MissingPartialTemplateHandler is not invoked for partial blocks

agross opened this issue · 2 comments

Describe the bug

I believe this should throw but it doesn't:

using HandlebarsDotNet;

class MissingPartial : IMissingPartialTemplateHandler
{
  public void Handle(ICompiledHandlebarsConfiguration configuration, string partialName, in EncodedTextWriter textWriter)
  {
    throw new NotImplementedException();
  }
}

Handlebars.Configuration.MissingPartialTemplateHandler = new MissingPartial();

var tmpl = Handlebars.Compile("{{#>foo}}\ndoesn’t-matter\n{{/foo}}");
tmpl(new object());

Expected behavior:

In the example above, a NotImplementedException should be thrown, i.e. MissingPartialTemplateHandler should be called because RegisterTemplate("foo", ...) has never been called.

Hello @agross
In your example it would not throw because you use partial-block: IMissingPartialTemplateHandler is not invoked and fallback is rendered instead.

Ok, thanks the the explanation. 11 days ago I was a Handlebars noob 😉 The issue can be closed.