Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled renderer ignores truthy conditions #80

Closed
janhohenheim opened this issue Nov 29, 2019 · 3 comments
Closed

Compiled renderer ignores truthy conditions #80

janhohenheim opened this issue Nov 29, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@janhohenheim
Copy link

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.

Romanx added a commit that referenced this issue Dec 1, 2019
#80

Turns out the compilation renderer didn't do a ton of things for truthy
checks that the standard renderer does. It now checks all numeric types
and wraps all the checks in a lambda that determines what the result is,
much like the hand-rolled version.
@Romanx Romanx self-assigned this Dec 1, 2019
@Romanx Romanx added the bug label Dec 1, 2019
@Romanx Romanx added this to the 1.6 milestone Dec 1, 2019
@Romanx
Copy link
Contributor

Romanx commented Dec 1, 2019

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.

Romanx added a commit that referenced this issue Dec 1, 2019
#80

Turns out the compilation renderer didn't do a ton of things for truthy
checks that the standard renderer does. It now checks all numeric types
and wraps all the checks in a lambda that determines what the result is,
much like the hand-rolled version.
@Romanx
Copy link
Contributor

Romanx commented Dec 1, 2019

@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.

@Romanx Romanx closed this as completed Dec 1, 2019
@janhohenheim
Copy link
Author

Thanks for the quick fixes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants