html-table 0.0.1 
Author Message
 html-table 0.0.1

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 <TR> represents a "row" and
<TD> and <TH> 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"

Quote:
}

# Create a TableRow object (<tr>) add it explicitly
row0 = HTML::TableRow.new{ |r|
   r.align   = "left"
   r.bgcolor = "red"

Quote:
}

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)

Quote:
}

# Create a TableData object (<td>) and add it explicitly
col0 = HTML::TableData.new{ |d|
   d.content = "Hello World!"
   d.nowrap  = true

Quote:
}

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

Quote:
}

# Finally, print the table
puts table.html

### OUTPUT ###
<table border=1 align='center'>
   <tr align='left' bgcolor='red'>
      <td nowrap>Hello World!</td>
   </tr>
   <tr align='right' bgcolor='green'>
      <td>foo</td>
      <td width=5 height=10>new bar</td>
   </tr>
</table>

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

Enjoy!

Dan



Sun, 27 Nov 2005 23:58:25 GMT  
 html-table 0.0.1

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

-a

Quote:
> 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 <TR> represents a "row" and
> <TD> and <TH> 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 (<tr>) 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 (<td>) 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 ###
> <table border=1 align='center'>
>    <tr align='left' bgcolor='red'>
>       <td nowrap>Hello World!</td>
>    </tr>
>    <tr align='right' bgcolor='green'>
>       <td>foo</td>
>       <td width=5 height=10>new bar</td>
>    </tr>
> </table>

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

> Enjoy!

> Dan

-a
--
  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328

  | Phone:  303-497-7238
  | Fax:    303-497-7259
  | ~ > ruby -e 'p(%.\x2d\x29..intern)'
  ====================================


Mon, 28 Nov 2005 02:07:24 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. grab html table[s] from html to files

2. awk scrips parsing html-table to plain text

3. ANNOUNCE: ClientTable: HTML table parsing

4. HTML-table

5. HTML Tables-need help

6. HTML tables outputted from Fortran

7. array in HTML table

8. extracting data from a html table

9. Displaying MySQL data in a custom HTML table

10. best method to parse data from html table?

11. How should I dynamically generate html tables?

12. extracting html table rows into a list

 

 
Powered by phpBB® Forum Software