To date, I've been using CoffeeScript to develop the JavaScript portion of my apps. I find that CoffeeScript keeps me from having to make as much of a mental leap between Ruby & JS every time I switch over. Also, coming from a Ruby background (and being too lazy at the moment to fully learn the intricacies of JavaScript) the syntax feels comfortable.

So naturally when I took a few first leaps into writing Google Apps Scripts (for some spreadsheets I was working on) I was looking for a way to use CoffeeScript to write functions for Google Apps. Turns out that this issue has been asked and answered over at StackOverflow.

The following CoffeeScript (compiled using the 'bare' option) will yield a function directly triggerable in Google Apps Scripts.

myFunction = ->
  Logger.log("I do something fancy in a Google Spreadsheet!")

`function thisFunctionIsTriggerable() { myFunction(); }`

Compiles to:

var myFunction;
myFunction = function() {
  return Logger.log("I do something fancy in a Google Spreadsheet!");
function thisFunctionIsTriggerable() { myFunction(); };

You should then be able to grab the thisFunctionIsTriggerable() function in the Scripts manager.

Blog Logo

Brandon Parsons



Brandon Parsons

My Personal Blog

Head back to the main page