Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created September 16, 2014 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderofsalvation/124ce37048867dfa1690 to your computer and use it in GitHub Desktop.
Save coderofsalvation/124ce37048867dfa1690 to your computer and use it in GitHub Desktop.
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":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment