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

Problem with inline if #121

Open
ablsc opened this issue Apr 14, 2022 · 1 comment
Open

Problem with inline if #121

ablsc opened this issue Apr 14, 2022 · 1 comment

Comments

@ablsc
Copy link

ablsc commented Apr 14, 2022

Didn't see anyone else raising this one, so here goes

Following works

var jexl = require("jexl")

jexl.addFunction("parseInt", (arg) => Number.parseInt(arg));
jexl.addFunction("isNaN", (arg) => Number.isNaN(arg));

jexl.evalSync("isNaN(parseInt(size)) == true ? 0 : parseInt(size)", { "size": "" });

Following throws the error: Token ? (question) unexpected in expression: isNaN(parseInt(size)) ?

var jexl = require("jexl")

jexl.addFunction("parseInt", (arg) => Number.parseInt(arg));
jexl.addFunction("isNaN", (arg) => Number.isNaN(arg));

jexl.evalSync("isNaN(parseInt(size)) ? 0 : parseInt(size)", { "size": "" });
@cmdcolin
Copy link

I ran into this also, glad there is a workaround with == true, but that is kind of odd

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

No branches or pull requests

2 participants