File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,12 +107,25 @@ def fortunes
107107 fortunes << { 'id' => 0 , 'message' => 'Additional fortune added at request time.' }
108108 fortunes . sort_by! { |item | item [ 'message' ] }
109109
110- buffer = String . new
111- buffer << TEMPLATE_PREFIX
112- fortunes . each do |item |
113- buffer << "<tr><td>#{ item [ 'id' ] } </td><td>#{ ERB ::Escape . html_escape ( item [ 'message' ] ) } </td></tr>"
114- end
115- buffer << TEMPLATE_POSTFIX
110+ rows = fortunes . map { |fortune | "<tr><td>#{ fortune [ 'id' ] } </td><td>#{ ERB ::Escape . html_escape ( fortune [ 'message' ] ) } </td></tr>" } . join
111+
112+ <<-HTML
113+ <!DOCTYPE html>
114+ < html >
115+ < head >
116+ < title > Fortunes</ title >
117+ </ head >
118+ < body >
119+ < table >
120+ < tr >
121+ < th > id</ th >
122+ < th > message</ th >
123+ </ tr >
124+ #{ rows }
125+ </ table>
126+ </ body>
127+ </ html>
128+ HTML
116129 end
117130
118131 def update_worlds ( count )
You can’t perform that action at this time.
0 commit comments