From: Ehsanul Hoque Date: 2009-11-05T14:25:25+09:00 Subject: Re: Create HTML files using RUBY --_14b5a869-d3ea-4bb4-9a9a-db3d5b2e6ae0_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > If I was going to write this myself I'd try something like: >=20 > def h1 > print "

" > yield > print "

" > end >=20 > h1 do > print "I'm a heading!" > end >=20 > =3D>

I'm a heading!

>=20 >=20 > By yielding to the block you allow yourself to nest other tags > inside of tags which is something you often have to do when writing > html. >=20 > Good luck. That's nice. I suggest that if the OP wants to use your suggested method=2C= maybe do it this way: class MyHtml def self.generate(&block) "\n" + self.new.instance_eval(&block) + "\n" end def body =20 "\n#{ yield }\n" end def h1 =20 "

#{ yield }

" end end MyHtml.generate do body do h1 { "This heading was generated by pure ruby" } end end Or just use builder or something :P (though it seems like that just might n= ot be allowed for the OP=2C as I suspect whoever is assigning this work exp= ects a real html generator implementation. - Ehsan =20 _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141665/direct/01/= --_14b5a869-d3ea-4bb4-9a9a-db3d5b2e6ae0_--