Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Document requirement for colon after functions #63

Open
andrewhavens opened this issue Jul 1, 2013 · 5 comments
Open

Document requirement for colon after functions #63

andrewhavens opened this issue Jul 1, 2013 · 5 comments

Comments

@andrewhavens
Copy link

I am using Backbone and Eco templates in my Rails application. My template has the following code:

  <% @collection.each (model)-> %>
    <% console.log model.get('name') %>
    <p><%= model.get('name') %></p>
    <p><%= model.get('description') %></p>
  <% end %>

For some reason, the HTML is blank. The name and description are not displayed. However, the console.log method outputs the correct data. What am I doing wrong?

@andrewhavens
Copy link
Author

Well I figured out the missing character. Apparently you need a colon after the arrow:

<% @collection.each (model)->: %>

Not sure why this is. It's not a CoffeeScript requirement. None of the code samples in the "blocks and capturing" section of the readme use a colon. Is this a bug, or an undocumented feature?

@andrewhavens
Copy link
Author

In case it matters, here are the eco-related version numbers in my Gemfile.lock file:

eco (1.0.0)
  coffee-script
  eco-source
  execjs
eco-source (1.1.0.rc.1)

@allenwyma
Copy link

It's not a bug. Whenever you use an if or loop you need a colon at the end and an end keyword to end it. This is how Eco works.

@andrewhavens
Copy link
Author

I'm going to change the title of this issue. The issue is really that this isn't fully documented in the readme. I'll try to submit a pull request by the end of the day.

@andrewhavens
Copy link
Author

Just submitted pull request #64 to address this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants