# \[ANN\] html-table 0.0.1

**URL:** <https://rubytalk.org/t/ann-html-table-0-0-1/6329>\
**Category:** ruby-talk\
**Created:** [11 June 2003 15:58 UTC](https://rubytalk.org/t/ann-html-table-0-0-1/6329 "2003-06-11T15:58:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berger\_Daniel2](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Berger\_Daniel2](https://rubytalk.org/u/Berger_Daniel2)\
**Post date:** [11 June 2003 15:58 UTC](https://rubytalk.org/t/ann-html-table-0-0-1/6329/1 "2003-06-11T15:58:25Z")

</div>

Hi all,

I’m happy to announce the release of html-table, a Ruby interface for  
generating HTML Tables without having to manually generate HTML tags  
yourself. While inspired by Perl’s HTML::Table, the API is only  
somewhat similar and the internals are completely different. The goal  
was to provide a widget-like interface where

 represents a “row” and and represent a column.

For now, I am releasing this as “Beta” because I have not entirely made  
up my mind about the API. Mostly, I’ll be waiting for feedback to see  
how you all like it. Also, please see the “Future Plans” section.

Synopsis:

require “html/table”

# Create a table

table = HTML::Table.new{ |t|  
t.border = 1  
t.align = “center”  
}

# Create a TableRow object () add it explicitly

row0 = HTML::TableRow.new{ |r|  
r.align = "left"  
r.bgcolor = “red”  
}

table.add\_tr(row0)

# Create a row implicitly, plus add content, on the fly

row1 = table.add\_tr{ |r|  
r.align = "right"  
r.bgcolor = "green"  
r.content = [“foo”,“bar”] # Add 2 TableData objects (columns)  
}

# Create a TableData object () and add it explicitly

col0 = HTML::TableData.new{ |d|  
d.content = "Hello World!"  
d.nowrap = true  
}

row0.add\_td(col0)

# Go back and configure row 1, column 1 (“bar” from above)

table.configure(1,1){ |d|  
d.content = "new bar"  
d.width = 5  
d.height = 10  
}

# Finally, print the table

puts table.html

### OUTPUT

| Hello World! |
| foo | new bar |

There are several examples included in the documentation as well.  
Please see the ‘doc’ and ‘doc/examples’ directories.

Enjoy!

Dan

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard1](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Ara.T.Howard1](https://rubytalk.org/u/Ara.T.Howard1)\
**Post date:** [11 June 2003 18:13 UTC](https://rubytalk.org/t/ann-html-table-0-0-1/6329/2 "2003-06-11T18:13:47Z")

</div>

i did something similar a while back - it was one of my first ruby libs so  
it’s pretty dated but you might find it interesting.

[http://eli.fsl.noaa.gov/eg/ruby/html/widget.rb](http://eli.fsl.noaa.gov/eg/ruby/html/widget.rb)

-a

> Hi all,
> 
> I’m happy to announce the release of html-table, a Ruby interface for  
> generating HTML Tables without having to manually generate HTML tags  
> yourself. While inspired by Perl’s HTML::Table, the API is only  
> somewhat similar and the internals are completely different. The goal  
> was to provide a widget-like interface where represents a “row” and
> 
> and represent a column.
> 
> For now, I am releasing this as “Beta” because I have not entirely made  
> up my mind about the API. Mostly, I’ll be waiting for feedback to see  
> how you all like it. Also, please see the “Future Plans” section.
> 
> Synopsis:
> 
> require “html/table”
> 
> # Create a table
> 
> table = HTML::Table.new{ |t|  
> t.border = 1  
> t.align = “center”  
> }
> 
> # Create a TableRow object () add it explicitly
> 
> row0 = HTML::TableRow.new{ |r|  
> r.align = “left”  
> r.bgcolor = “red”  
> }
> 
> table.add\_tr(row0)
> 
> # Create a row implicitly, plus add content, on the fly
> 
> row1 = table.add\_tr{ |r|  
> r.align = “right”  
> r.bgcolor = “green”  
> r.content = [“foo”,“bar”] # Add 2 TableData objects (columns)  
> }
> 
> # Create a TableData object () and add it explicitly
> 
> col0 = HTML::TableData.new{ |d|  
> d.content = “Hello World!”  
> d.nowrap = true  
> }
> 
> row0.add\_td(col0)
> 
> # Go back and configure row 1, column 1 (“bar” from above)
> 
> table.configure(1,1){ |d|  
> d.content = “new bar”  
> d.width = 5  
> d.height = 10  
> }
> 
> # Finally, print the table
> 
> puts table.html
> 
> ### OUTPUT
> 
> | Hello World! |
> | foo | new bar |
> 
> There are several examples included in the documentation as well.  
> Please see the ‘doc’ and ‘doc/examples’ directories.
> 
> Enjoy!
> 
> Dan

-a

> **···**
>
> ## On Thu, 12 Jun 2003, Daniel Berger wrote:
> 
> ====================================
> 
> > Ara Howard  
> > NOAA Forecast Systems Laboratory  
> > Information and Technology Services  
> > Data Systems Group  
> > R/FST 325 Broadway  
> > Boulder, CO 80305-3328  
> > Email: [ara.t.howard@noaa.gov](mailto:ara.t.howard@noaa.gov)  
> > Phone: 303-497-7238  
> > Fax: 303-497-7259  
> > ~ \> ruby -e ‘p(%.\x2d\x29..intern)’  
> > ====================================
