Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Security Article Part 3 - 11

View data_helper.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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.