node-red-contrib-jexl

a node to use the JEXL expression language

Usage no npm install needed!

<script type="module">
  import nodeRedContribJexl from 'https://cdn.skypack.dev/node-red-contrib-jexl';
</script>

README

node-red-contrib-jexl

node-red node to parse and evaluate an expression against a context using jexl

What does it do?

The jexl node expects a msg.payload that contains a valid jexl expression, e.g.

(data.someprop + 2) > 42 ? "cannot be" : "this is right"

It also expects some data in the msg.context property. The expression is parsed and evaluated against this data, e.g.

{
    "data": {
        "someprop": 40      
    }
}

This would result in this string: this is right in msg.payload.

Ideas to improve this node

  • set the input property name for payload / context
  • allow to add operators or transforms by passing in more message parts, that contain javascript code
  • allow to set xml / yaml transforms to run these formats with the node.

If you have a feature request, please contact me or open a pull request.