Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.24k stars 214 forks source link

Handlebars.Configuration.MissingPartialTemplateHandler is not invoked for partial blocks #475

Closed agross closed 2 years ago

agross commented 2 years ago

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.

oformaniuk commented 2 years ago

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

agross commented 2 years ago

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