How to not encapsulate Coffeescript
Posted
by
JellicleCat
on Stack Overflow
See other posts from Stack Overflow
or by JellicleCat
Published on 2012-06-13T16:23:45Z
Indexed on
2012/06/17
21:16 UTC
Read the original article
Hit count: 201
I don't know whether all coffeescript compilers wrap their scripts in anonymous functions, but that's what I see Rails doing. How can I disable this encapsulation?
I want to put several initializing functions in a single coffeescript file, then call one of them from an on-page <script>
tag (so that each page calls a different initializer). This can't be if the initializing functions are encapsulated.
Coffeescript initializer functions:
initializerA = -> console.log 'foo'
initializerB = -> console.log 'bar'
On-page code:
<script>$(document).ready(initializerA)</script>
Sys: coffee-rails 3.2.1, Rails 3.2.3, Ruby 1.9.3
© Stack Overflow or respective owner