Skip to content

Instantly share code, notes, and snippets.

@keolo
Created May 24, 2011 01:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save keolo/988010 to your computer and use it in GitHub Desktop.
Save keolo/988010 to your computer and use it in GitHub Desktop.
# app/assets/javascripts/application.js
//= require_tree .
# app/assets/javascripts/application.js.coffee
@application =
awesomeFunction: (params) ->
console.log(params)
# app/assets/javascripts/home.js.coffee
$ ->
application.awesomeFunction(['Hey', 'there'])
@victusfate
Copy link

The method you show here uses node's require by precompiling the cofffeescript?

Heyo keolo, I have bumped into this a number of times recently
clientside I attach functions to window and node side I attach functions to export.
http://stackoverflow.com/questions/4214731/coffeescript-global-variables/4215132#4215132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment