Created
June 25, 2012 19:16
-
-
Save iHiD/2990648 to your computer and use it in GitHub Desktop.
Security Article Part 3 - 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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><b>xyz</b></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