[Newbies] What is the best way to generate HTML from an array of arrays

Andy Burnett andy.burnett at knowinnovation.com
Mon Oct 13 23:45:15 UTC 2008


I want to display a threaded discussion. The threads will probably be stored
in an array, and n levels of comments would be in nested arrays, e.g.:

model := #('one' 'two' ('two a' 'two b') 'three').

I want to generated

OL
   LI  one  /LI
   LI  two  /LI
   OL
       LI  two a /LI
...
/OL


If there were no embedded arrays I would just do something like:

model do: [:each| html listItem: (each asString)]

But as soon as I have embedded arrays, my mind goes a bit blank and I start
thinking about recursive routines, and that doesn't seem very Smalltalk at
all!  So, what is the OO way to do this?

Thanks
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20081013/14a17286/attachment.htm


More information about the Beginners mailing list