Handlebars-Net / Handlebars.Net

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

Nested partial block loses passed hash context. #515

Closed oformaniuk closed 2 years ago

oformaniuk commented 2 years ago

Describe the bug

Nested partial block loses passed hash context.

Expected behavior:

Nested partial block has access to passed hash context.

Test to reproduce

[Fact]
public void ValidContextInNestedPartialBlock()
{
    const string template = @"{{#> [a/b] c=this }}{{c.value}}{{/ [a/b] }}";
    const string partial = "{{c.value}} {{> @partial-block }}";

    var handlebars = Handlebars.Create();
    handlebars.RegisterTemplate("a/b", @partial);

    var callback = handlebars.Compile(template);
    var result = callback(new { value = 42 });

    const string expected = @"42 42";
    Assert.Equal(expected, result);
}