StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiled renderer ignores truthy conditions

janhohenheim opened this issue · comments

MCVE:

var stubbleRenderer = new StubbleCompilationBuilder().Build();
var render = stubbleRenderer.Compile<Dummy>("{{#Condition}}foo{{/Condition}}");
var view = render(new Dummy());
// view is now string.Empty
       
public class Dummy
{
    public string Condition { get; } = "Truthy value"
}

When using the default renderer, this code renders "foo". However, the compiled renderer sees Condition as false and doesn't render anything.

Hi there,

Thanks again for the great reproduction, while unpicking this I found plenty of other cases where this didn't work, our test coverage was lacking and we just lacked feature parity with the standard renderer.

I've changed how the truthy checks work, added more test coverage around that area and at the same time simplified some of the generated code.

I'll aim to get this released tomorrow. Thanks for opening this issue and let us know if you have any other issues.

@jnferner Thanks very much for reporting this. It has been fixed in release 1.6.3 and has now been released on nuget.

Please let us know if you have any other issues.

Thanks for the quick fixes :)