showell/CoffeeCoffee — Issue #3: Getting things to work in the client
Author: gkz
Created: 2011-11-27 04:31:53+00:00
State: open

I spent a while hacking CoffeeCoffee in a very ugly way (changing the js directly) to get it to work on the client side. I am unfamiliar with git or github, and I changed the js directly instead of the CoffeeScript, so I am just going to list all the changes required here.

First of all, I recommend that you create a namespace for everything, say CofffeeCoffee ie
window.CoffeeCoffee = {}
Then, you can assign everything as window.CoffeeCoffee.something = "blah"

### nodes_to_json
I would recommend you add an actual nodes to json method, which takes in the actual nodes, not just code (you can have both)

### builder
remove the window.Debugger = debugger, this just creates errors because it does't exist
Now, for the builder to work in the client it actually needs to return a string, not just console.log as that doesn't do anything helpful. What you could do is add a array,
data = []
at the top level of builder
then, in PUT, add
data.push(TAB + s)
In transcompile, then you must add
data = []
at the top to clear out anything previous in there, then at the end return
data.join('\n')
so that you return a string that can be used

### round_trip
add
indenter = window.indenter (or, window.CoffeeCoffee.indenter)
at the top level so that it is available
window.transcompile and window.Debugger need to be removed as they cause errors, and a to_coffee method aliasing handle_data needs to be added
in the parser, again, console.log does little for the client, so get the results of the loop, and return results.join('\n') to return a string that can be used

### indentor
the big_block and small_block methods need to be exported to the window