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

Replacement is not occured #60

Closed
dejx opened this issue Jul 15, 2015 · 3 comments
Closed

Replacement is not occured #60

dejx opened this issue Jul 15, 2015 · 3 comments
Labels

Comments

@dejx
Copy link
Contributor

@dejx dejx commented Jul 15, 2015

Hello,

I'm attaching the code sample below about the issue i'm experiencing

[TestMethod]
public void Handlebar_Test_3()
{
    var template =
        "{{#home}}Welcome Home{{/home}}{{^home}}Welcome to {{newCity}}{{/home}}";

    var data = new Dictionary<string,object>();
    data["newCity"] = "New York City";
    data["oldCity"] = "Los Angelos ";
    data["home"] = false;

    var compiler = Handlebars.Compile(template);
    var result = compiler.Invoke(data);
    Assert.AreEqual("Welcome to New York City", result);
}

The result is

   Expected:<Welcome to New York City>. Actual:<Welcome to >. 
@rexm
Copy link
Collaborator

@rexm rexm commented Jul 17, 2015

I had to go back to the Handlebars and Mustache specs to try to understand this one, and I'm still having a bit of a hard time. The #key syntax denotes a "section", which is supposed to use the non-falsy value as the context for the inner block. But in this case the value is a boolean and the context inside the block is still actually the parent context. So we may need to look at the actual implementation to understand if there is some type checking going on, or something else.

@rexm
Copy link
Collaborator

@rexm rexm commented Jul 18, 2015

Based on some further investigation, it looks like the JS library is indeed doing a very specific type check on the section key, and if the value is a boolean type it treats the section expression as an if-block instead of a with-block or an iterator block.

This specific check has not been implemented in the .NET library.

@rexm rexm added the bug label Jul 18, 2015
@rexm rexm closed this in e6cb976 Aug 8, 2015
@rexm
Copy link
Collaborator

@rexm rexm commented Aug 8, 2015

NuGet 1.4.3

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

Successfully merging a pull request may close this issue.

None yet
2 participants