Ok this may seem stupid and I have googled extensively using various different keywords and terms, attempted a lot of various different methods and tried to my very last breadth and cannot seem to figure out how to do this. All I want is stdout in a rails app without needing to break my block.
Currently, when I do a block of ruby code in my rails app and want to output the value I do the following
<% somearray do | item | %>
<%= item %>
<% end %>
To me this is quite messy, I know coming from a PHP background it’s not how one should imagine how to code in rails but coming from many different environments I like my code to look nice to me. It’s very easy to encapsulate every single line with <% %> but I’d prefer my code to be my code and my mark up to be my mark up.
What I’d like, but which doesn’t work, is….
<%
somearray do | item |
whatever item #whatever being puts or similar
end
%>
It’s solely for the aesthetics of the code and not for what it produces but for me, a very long time programmer, it means a lot and a lot of time saved when trying to see where and when code blocks begin and end.
Thanks in advance,
Jay (c0ld)
You can use
concat. From the docs: