Closed wasimshariff closed 4 years ago
Hi there, glad you're enjoying Jexl!
You can absolutely do that -- you just need to change to the transform syntax. First, create the "toUpperCase" transform like this (you only need to do this once):
jexl.addTransform('toUpperCase', (str) => str.toUpperCase())
And now you can use that transform like this:
jexl.evalSync('name.first|toUpperCase', context)
Done! Let me know how that works out.
It works...Thank you Tom!!!!
H Tom,
Thanks a ton for such a great library!!!
I am trying to do something similar to one given below.
const context = { name: { first: 'Sterling', last: 'Archer' } }
jexl.eval('name.first.toUpperCase()', context)
My use case is , i get the expression from some other source dynamically. I have few prototype methods that i need to execute as part of expression. Is there a way to do this ?
Right now, above snippet returns an error while trying to call toUpperCase on string .
Thank you.