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

Helpers cannot have negative integer parametres? #422

Closed
raix opened this issue Jan 30, 2013 · 3 comments
Closed

Helpers cannot have negative integer parametres? #422

raix opened this issue Jan 30, 2013 · 3 comments
Labels

Comments

@raix
Copy link

raix commented Jan 30, 2013

Hi, seems a helper cant recieve negative integer, can you verify?
Negative Integer parsed as id?

Only place I can see something supporting my issue is:
handlebars.js / src / handlebars.l ln 45:

<mu>[0-9]+/[}\s]

Not sure if following would work: (not tested)

<mu>-?[0-9]+/[}\s]

Thanks

@kpdecker
Copy link
Collaborator

Confirmed, this is a bug. Failing test:

test("negative number literals work", function() {
  var string   = 'Message: {{hello -12}}';
  var hash     = {};
  var helpers  = {hello: function(times) {
    if(typeof times !== 'number') { times = "NaN"; }
    return "Hello " + times + " times";
  }};
  shouldCompileTo(string, [hash, helpers], "Message: Hello world -12 times", "template with a simple String literal");
});

@raix
Copy link
Author

raix commented Feb 16, 2013

Thanks

@sunng87
Copy link

sunng87 commented Apr 11, 2013

By the way, I still find that handlebars doesn't support negative integer as hash. for example {{#ifgreater a compare=-1}}, the "compare" is undefined from helper.

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

3 participants