Open seocochan opened 3 years ago
Hi Tom
I'm currently working on implementing simple rules engines and considering jexl as a DSL to adopt.
jexl
I found out that some implementations like this provides calling methods with namespace(class names)
So I tried some expressions like FooService.doSomething() or FooService#doSomething()on jexl but it fails.
FooService.doSomething()
FooService#doSomething()
here is the code I tried on runkit
const jexl = require("jexl") const input = { order: { total: 100000, }, coupon: { status: 'ACTIVE' }, } jexl.addFunction('OrderService.discountOrder', (order, rate) => order.total = order.total * (1.0 - rate)) const rules = [ `OrderService.discountOrder(order, 0.2)`, // mutate passed object ] const results = await Promise.all(rules.map(rule => jexl.eval(rule, input))) console.log(results) console.log(input.order)
I guess there're some reserved tokens like defined on grammar.js but is there any way to avoid these behavior or any suggestions to achieve my point?
grammar.js
Thanks.
Hi Tom
I'm currently working on implementing simple rules engines and considering
jexl
as a DSL to adopt.I found out that some implementations like this provides calling methods with namespace(class names)
So I tried some expressions like
FooService.doSomething()
orFooService#doSomething()
onjexl
but it fails.here is the code I tried on runkit
I guess there're some reserved tokens like defined on
grammar.js
but is there any way to avoid these behavior or any suggestions to achieve my point?Thanks.