The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
html-table, now with DSL syntax!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
html-table, now with DSL syntax! Posted: Aug 2, 2006 5:52 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: html-table, now with DSL syntax!
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
Hey, all the cool kids are doing DSL's these days, so naturally I have to follow suit. In my case I adopted a DSL-style syntax for the html-package. Yes! I, too, can call instance_eval(&block)! I wanted this in preparation for my Rails project which I'll be getting back into, now that I'm out of report hell again.

Here was the old syntax:
table = HTML::Table.new do |t|
   t.align   = 'left'
   t.bgcolor = 'red'
   t.content = [['foo','bar']]
end

Here's the new syntax:
table = HTML::Table.new do
   align    'left'
   bgcolor  'red'
   content  [['foo', 'bar']]
end

In addition, I now support physical tags for content:
table = HTML::Table.new do
   content 'foo' do
      bold   true
      italic true
   end
end

I also added 'style' and 'class' CSS tag support. You can still use the old syntax, too, if you're worried about backwads compatibility (or if you happen to prefer that style). And now, to add a .to_html_table method to ActiveRecord. :)

Read: html-table, now with DSL syntax!

Topic: How I learned Ruby Previous Topic   Next Topic Topic: How I Learned Ruby

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use