Unwrap text
Report abuse
test.rb
require 'erb'
template = File.readlines("test.erb").join
newarray = []
newarray << ["one", "two", "three"]
newarray << ["one", "two", "three"]
newarray << ["one", "two", "three"]
html = ERB.new(template, 0, "<>")
puts html.result(binding)
test.erb
<style type="text/css">
TABLE.data { font-family: arial,serif; font-size: 10pt; background-color: white; padding: 2; }
TH.data { font-family: arial,serif; font-size: 10pt; background-color: white; text-align: left; background-color:
.serviceOK { font-family: arial,serif; font-size: 10pt; text-align: left; background-color:
.serviceCRITICAL { font-family: arial,serif; font-size: 10pt; text-align: left; background-color:
</style>
<TABLE BORDER=0 CLASS='data'>
<TR><TH CLASS='data'>Host</TH><TH CLASS='data'>Service</TH><TH CLASS='data'>% Uptime</TH>
<% newarray.each do |line| %>
<tr><td CLASS='data'><%= line[0] %></td><td CLASS='serviceOK'><%= line[1] %></td><td CLASS='serviceCRITICAL'><%= line[2] %></td></tr>
<% end %>
output
<style type="text/css">
TABLE.data { font-family: arial,serif; font-size: 10pt; background-color: white; padding: 2; }
TH.data { font-family: arial,serif; font-size: 10pt; background-color: white; text-align: left; background-color:
.serviceOK { font-family: arial,serif; font-size: 10pt; text-align: left; background-color:
.serviceCRITICAL { font-family: arial,serif; font-size: 10pt; text-align: left; background-color:
</style>
<TABLE BORDER=0 CLASS='data'>
<TR><TH CLASS='data'>Host</TH><TH CLASS='data'>Service</TH><TH CLASS='data'>% Uptime</TH>
<tr><td CLASS='data'>one</td><td CLASS='serviceOK'>two</td><td CLASS='serviceCRITICAL'>three</td></tr>
<tr><td CLASS='data'>one</td><td CLASS='serviceOK'>two</td><td CLASS='serviceCRITICAL'>three</td></tr>
<tr><td CLASS='data'>one</td><td CLASS='serviceOK'>two</td><td CLASS='serviceCRITICAL'>three</td></tr>