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

HandlebarsUndefinedBinding thrown for null ExpandoObject values #351

Closed
andycnguyen opened this issue May 29, 2020 · 1 comment · Fixed by #359
Closed

HandlebarsUndefinedBinding thrown for null ExpandoObject values #351

andycnguyen opened this issue May 29, 2020 · 1 comment · Fixed by #359

Comments

@andycnguyen
Copy link

andycnguyen commented May 29, 2020

I've been trying to convert my Handlebars models to ExpandoObjects, as recommended in various issues here. However, I've found that that a HandlebarsUndefinedBinding exception is thrown for null values.

For example, I'd like to make use of templates and models like the following:

{{#if PerhapsNull}}
     It's not null
{{else}}
     It's null
{{/if}}
dynamic data = new ExpandoObject();
data.PerhapsNull = null;

This doesn't work, however, due to the aforementioned exception. I'm aware that I could suppress this exception by setting ThrowOnUnresolvedBindingExpression = false, but I'd rather not do this. (And it seems to me that, in the example I've given, the expression in question should not be considered unresolved.)

@oformaniuk
Copy link
Member

I've tested you problem on my fork zjklee/Handlebars.CSharp and it works.
You can try using it until changes are merged to the main repo.

oformaniuk added a commit to oformaniuk/Handlebars.Net that referenced this issue May 30, 2020
oformaniuk added a commit to oformaniuk/Handlebars.Net that referenced this issue May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants