In the below code, the value of actual1 is "," and the value of actual2 is ",False,I shouldn't show up!,"
I expected the partial "displayList" to have a new context, which would be null since "TheList" is never assigned. I expected the #each to not iterate through anything.
Test to reproduce
private class ClassWithAList
{
public IEnumerable<string> TheList { get; set; }
}
private class ClassWithAListAndOtherMembers
{
public IEnumerable<string> TheList { get; set; }
public bool SomeBool { get; set; }
public string SomeString { get; set; } = "I shouldn't show up!";
}
[Fact]
public void WeirdBehaviour()
{
var handlebars = Handlebars.Create();
handlebars.RegisterTemplate("displayListItem", "{{this}},");
handlebars.RegisterTemplate("displayList", "{{#each this}}{{> displayListItem}}{{/each}}");
var template = handlebars.Compile("{{> displayList TheList}}");
var actual1 = template(new ClassWithAList());
var actual2 = template(new ClassWithAListAndOtherMembers());
var expected = "";
Assert.Equal(expected, actual1);
Assert.Equal(expected, actual2);
}
In the below code, the value of actual1 is "," and the value of actual2 is ",False,I shouldn't show up!,"
I expected the partial "displayList" to have a new context, which would be null since "TheList" is never assigned. I expected the #each to not iterate through anything.
Test to reproduce