jcbridwe jcbridwe - 4 months ago 23
CoffeeScript Question

Inserting labeled javascript/json into a coffee format

I am trying to use Flot tooltip in a coffee file, but I am having trouble inserting the necessary labelled javascript/json code into the coffee code. I've tried the js2coffee converter tool, but it doesn't seem to work. Here's the code, I am trying to translate into coffee; any suggestions?

grid: { hoverable: true },
tooltip: {
show: true,
content: "y: %y"
}

Answer

The object can be written in CoffeeScript as follows:

somevar =
  grid:
    hoverable: true
  tooltip:
    show: true
    content: 'y: %y'

You can see the conversion to JavaScript live on coffeescript.org

Comments