Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why a colon at the end of a block statement? #57

Closed
perklet opened this issue Feb 15, 2014 · 1 comment
Closed

Why a colon at the end of a block statement? #57

perklet opened this issue Feb 15, 2014 · 1 comment

Comments

@perklet
Copy link

perklet commented Feb 15, 2014

from the official site:

<% if @links?.length : %>
    <ul>
        <% for link in @links : %>
            <%- linkHelper link %>
        <% end %>
    </ul>
<% else : %>
    <p>List is empty</p>
<% end %>

What is the purpose of using a colon at the end? It's not a CoffeeScript syntax.
And will it be removed in the future?

@baryshev
Copy link
Owner

baryshev commented Mar 8, 2014

CoffeeScript uses indentation to denote code blocks. We can't use indentation for this purpose inside of templates, because templates have it's own indentation in HTML. Colon and end statements is not a part of CoffeeScript, it's a part of ECT. Also ECT uses this syntax to be fully compatible with ECO, because ECT is positioned as fast and more powerful ECO alternative.

@baryshev baryshev closed this as completed Apr 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants