3

I'm currently using spinejs and eco template system in rails project. It's work perfectly on my Mac, however there is a strange indent error when I deploy it on Windows. And the code is:

<div class="contacts">
    <% for contact_record in @unchecked_contact_records : %>
        <%= contact_record %><br>
    <% end %>
</div>

And the error message is:

ExecJS::ProgramError in Admin#dashboard

Showing C:/Users/rayshih.mama-PC/workspace/showwin_ror_1_5/app/views/layouts/application.html.erb where line #6 raised:

Error: Parse error on line 2: Unexpected 'INDENT'
  (in C:/Users/rayshih.mama-PC/workspace/showwin_ror_1_5/app/assets/javascripts/admin/views/dashboard/contacts.jst.eco)

Extracted source (around line #6):

3: <head>
4:   <title>Show Win Printing Service</title>
5:   <%= stylesheet_link_tag    "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>

I thought this is a problem only on block statement, but by this experiment:

<div class="contacts">
    <% if true: %>
        <%= "hello world" %><br>
    <% end %>
</div>

In this experiment, there is no error. So this is not a block statement bug. Seems like it only happen on for loop statement, but why?

mu is too short
  • 426,620
  • 70
  • 833
  • 800
Ray Shih
  • 933
  • 8
  • 18
  • 1
    Could it possibly be an end-of-line issue? Do your files on Windows have CR-LF line endings or just LFs? – mu is too short Nov 12 '11 at 05:48
  • currently just LFs, but two situation above are all LFs. One is ok, the other is not :( – Ray Shih Nov 12 '11 at 09:21
  • I'd tried the CR-LFs line endings too, still not work :( – Ray Shih Nov 12 '11 at 09:25
  • So this is actually a JavaScript question that has nothing at all to do with Ruby or Rails then? – mu is too short Nov 12 '11 at 19:00
  • Rails will call ExecJS to run ECO system to compile the template, and this process is done on server. I gauss the problem is in the process that after eco system compile the template to coffeescript, it will save to a temp file, then read it again to compile to javascript. – Ray Shih Nov 12 '11 at 19:09
  • What backed are you using for ExecJS? Are you using the same js runtime in both platforms? – Relax Nov 24 '11 at 00:59

1 Answers1

2

This is a known issue: https://github.com/sstephenson/eco/issues/29

I followed the instructions from one of the commenters and installed Node: http://nodejs.org/ Node is automatically added to your path so once you have checked node is in the path by typing "node" at the command prompt, restart your rails server and it should be fixed.

alanramsay
  • 86
  • 1
  • 4