I have a question about ruby code delimiters.
This code block:
<% end -%>
What does the “-” before the ending delimiter signify? My code errored
out, I thought those were
misprints or something in the book, but added them and it works. I don’t
recall seeing that in the
Ruby appendix, and I’ve never seen this convention before (like with JSP
or ASP).
TIA
Tom
http://www.pixelmech.com/
Hi,
Tom Dell’Aringa wrote:
<% end -%>
What does the “-” before the ending delimiter signify? My code errored out, I thought those were
misprints or something in the book, but added them and it works. I don’t recall seeing that in the
Ruby appendix, and I’ve never seen this convention before (like with JSP or ASP).
Simply prunes the \n after ‘end’.
— Jean-Christophe M. [email protected] wrote:
Simply prunes the \n after ‘end’.
Thanks - Had I literally read the next line… I would have known
that. Nice feature though!
Tom
http://www.pixelmech.com/
Tom:
the final -%> differs from %> in that if there is no text produced
between the delimiters then it takes no space on the page. I believe
the standard delimiter %> would take up some space whether or not it
needed to. A good example of when this may be useful (I used it the
other day) is if you were making invoices and had something like
<% org.company_name %> #no need for fancy delimiter as all
companies will have names
<% org.address1 %> #as above
<% org.address2 -%> #note fancy delimiter because many
companies don’t have an address2 and we don’t want a blank line
appearing in the address.
bruce