1

I just set up CoffeeScript (I'm also using Jade) for Meteor and it seems that my helpers (rendered and events functions too) do not work anymore.

Template.signIn.helpers
    showForgotPassword: () ->
        return Session.get('showForgotPassword')

The code seems to be properly generated but is embraced in an anonymous function.

I'm getting the following error in the web console:

Uncaught TypeError: Cannot call method 'helpers' of undefined (account.coffee:12)

I'm wondering whether the code is run before the page is fully loaded or if it is due to something else. I've also tried this but nothing changed (though it seems to work in this tutorial):

root = global ? window

root.Template.signIn.helpers
    showForgotPassword: () ->
        return Session.get('showForgotPassword')
Julien Le Coupanec
  • 7,742
  • 9
  • 53
  • 67

3 Answers3

1

The problem is fixed when I wrap my code with Meteor.startup (see David Weldon post).

if I put .jade and .coffee into same level folder meteor will load .coffee before .jade, then it causes no such template. To prevent this, you can prefix jade files with _.

Community
  • 1
  • 1
Julien Le Coupanec
  • 7,742
  • 9
  • 53
  • 67
  • 3
    It's unfortunate that we have to play all these games just to get jade to work. I suspect that after the new rendering engine is stable, it will be a lot easier to add proper jade support. For now, I'm sticking with my cakefile solution. – David Weldon Jan 25 '14 at 20:57
0

Thanks for the great pointer @Julien.

I run into this issue about a few hours back and have been breaking my head since.

What I did instead of the _ approach, was to name my jade files as .html.jade and my coffeescript files as .js.coffee

That way the jade files are loaded before the coffee files and everything works.

The advantage to the _ approach is that related jade and coffee files are together.

Hope this helps.

ksprashu
  • 111
  • 5
0

I think this is solved in meteor-jade v0.2.2

AZ.
  • 7,333
  • 6
  • 44
  • 62