Idva Idva - 6 months ago 19x
Ruby Question

Calling Coffeescript variables in Slim

Im trying to declare a coffescript function and call it later in the code. I'm pretty new to this, and can't seem to find anything on it.

Here is the code im working on, as you can see I try to call the square function:

@square = (x) -> x * x

p square(3)

Here i want to get a p-tag containing "9"


You can do it like so

   document.write @square(3) 

But !!NEVER EVER!! write such horrible things. In ROR Slim templates are for ruby only. And please don't define any methods there.