Skip to content

@iHiD /data_helper.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Security Article Part 3 - 11
module DataHelper
# Expects a nested array such as:
# [[1,'Jez','iHiD'], [2,'Bob','<b>xyz</b>']]
#
# and outputs:
# <table>
# <tr><td>1</td><td>Jez</td><td>iHiD</td></tr>
# <tr><td>2</td><td>Bob</td><td>&lt;b&gt;xyz&lt;/b&gt;</td></tr>
# </table>
def data_to_table(data)
output = "<table>"
data.each do |row|
output << "<tr>"
row.each do |cell|
output << "<td>#{cell}</td>"
end
output = "</tr>"
end
output << "</table>"
output.html_safe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.