Scoped variables with Normal Template
by gmosx, at 19 Feb 2010<% message.comments.last.tap do |comment| %>
<li><%= comment.creator %></li>
<% end %>While .tap() introduces a scope it still smells as bad style. A more fundamental flaw lies underneath: the lack of true separation of data and presentation. Consider the following alternative using Normal Templates:
{:reduce comments}
<li>{=creator}</li>
{/:reduce}or the equivalent shorter version:
{:r comments}
<li>{=creator}</li>
{/:r}Scoped, safer, shorter and more readable. Do yourself and favor and switch to a push-style templating engine like Normal Template.


