-
Notifications
You must be signed in to change notification settings - Fork 95
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
Cannot index into static array or object #115
Comments
Some context for this is I'm trying to write an expression that give me a random string from a static list.
Am I going about this the wrong way? |
Oh wow -- I see why that's happening. Definitely a bug! Until this is fixed, you could throw this into a transform function: jexl.addTransform('random', (ary) => {
const idx = Math.floor(Math.random() * ary.length)
return ary[idx]
}) Now your expression becomes |
This will do for now. Thanks! |
To avoid raising duplicate issues it looks as if what chetbox has raised means static JSON as parameters to functions isn't currently possible with jexl right now. The following expression
raises the error
By changing the expression to the following and parsing the string in aFunction as JSON does work
I wondered if transforms might help but parsing bombs out just the same. |
Hi! Thanks for this great library!
I just came across something I had assumed would work but it doesn't seem to.
(Playground link)
Gives this error:
Similarly,
(Playground link)
Gives this error:
It's possible to index into and array or an object if it's part of the Jexl context but seemingly not statically like this.
The text was updated successfully, but these errors were encountered: