I was wondering how I could perform output in multiple lines in Sinatra. Eg.
get '/test' do
array= ["one","two","three"]
"#{array.each { |elem| elem}}"
end
ideally would have output:
one
two
three
not onetwothree
I’m fairly new to Sinatra and Ruby (first day of study) so please apology me for basic question (can’t find answer anywhere)
Plain text newlines
or for HTML line breaks:
Reference: http://ruby-doc.org/core/classes/Array.html#M002182
Note: It’s not a sinatra problem. Newlines are intepreted differently in HTML, plain newlines aren’t interpreted as such by HTML, unless they are inside a
<pre>block; outside<pre><br>is used for linebreaks.