run coffee-script

For all you coffee-heads out there, its pretty simple to do coffeescript in node-red. Only thing you should do is enable it :)

To enable it, put this in your settings.js-file:

functionGlobalContext: { 
  coffeescript:require('coffee-script'),
}
[{"id":"adbeae99.52415","type":"debug","name":"","active":false,"console":"true","complete":"true","x":636,"y":102,"z":"886b17b1.7794e8","wires":[]},{"id":"423d7a8d.bdc284","type":"function","name":"process","func":"msg.payload = eval( context.global.coffeescript.compile( msg.payload ) );\nreturn msg;","outputs":1,"x":482,"y":102,"z":"886b17b1.7794e8","wires":[["adbeae99.52415"]]},{"id":"356fe08c.ca902","type":"inject","name":"","topic":"","payload":"test","payloadType":"string","repeat":"","crontab":"","once":false,"x":132,"y":102,"z":"886b17b1.7794e8","wires":[["1a871e8d.e578e1"]]},{"id":"1a871e8d.e578e1","type":"template","name":"coffeescript","template":"foo =\n  bar: 1\n\nreturn JSON.stringify foo\n","x":323,"y":102,"z":"886b17b1.7794e8","wires":[["423d7a8d.bdc284"]]},{"id":"8d0d5680.72f2a8","type":"comment","name":"how it works","info":"\nTo make this work put this in your settings.js-file:\n\n    functionGlobalContext: { \n      coffeescript:require('coffee-script'),\n    }\n","x":413,"y":44,"z":"886b17b1.7794e8","wires":[]}]
coderofsalvation

Flow Info

created 2 years, 11 months ago

Node Types

Core
  • comment (x1)
  • debug (x1)
  • function (x1)
  • inject (x1)
  • template (x1)

Tags

  • coffeescript
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option