"Sam Sungshik Kong" <ssk / chol.nospam.net> wrote in message news:<rMmvc.63963$Wf7.46733 / newssvr29.news.prodigy.com>... > Thanks to all who replied to my question. > > I want to mention one thing. > One drawback of ruby's #{name} mechanism is that the variable 'name' must > exist before I setup the format and another drawback is that when I setup > the format the result string is already made (returned) and cannot be > delayed (if I'm correct...). > Sometimes I want to make the format first, especially when I write scripts > for web pages with python (now ruby :-)). > > In python for ASP, for instance, I frequently write the following style > code. > > html = """ > <tr> > <td>%(name)s</td> > <td>%(age)d</td> > </tr> > """ > di = { > "name": get_name_from_db(), > "age": get_age_from_db() > } > Response.Write(html % di) > > Well, I may change the sequence (get the values first and setup the > formatting string). > However, in the above case, formatting is outer bound and the values are > details. > My brain feels more comfortable in this way...;^) > > Sam > > > what about?... require 'ostruct' di = OpenStruct.new html = """ <tr> <td>%s</td> <td>%d</td> </tr> """ Response.Write(html % [di.name = "Sam", di.age = 34]) Or, something similar to that.