Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested partial block loses passed hash context.

oformaniuk opened this issue · comments

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);
}