Hmm... an untested suggestion... <table> $cells:{ row | <tr>$row:{ cell | <td>$cell$</td>}$</tr>}$ </table>
(i.e. nested iteration) or to encompass the table call inside, $cells:{ row | <tr>$row:{ cell | <td>$cell$</td>}$</tr>}:{<table>$it$</table>}$ Regards, Sterl. On Thu, Sep 18, 2008 at 8:16 AM, Thomas Hartman < [EMAIL PROTECTED]> wrote: > I am trying to use HStringTemplate for generating html tables, for use > in http://happstutorial.com:5001 > > The best I could do is below. Seems awfully kludgy. > > Can someone suggest a better way, which keeps me inside the > StringTemplate way of doing things? (Eg, no suggestions to use HTML.* > libraries, which are nice for some things but are a higher barrier to > entry than just jumping in and writing html.) > > Some kind of map structure... for each... ? > > Thanks for any help! > > thomas. > > {-# LANGUAGE NoMonomorphismRestriction #-} > import Text.StringTemplate > import Control.Applicative > import qualified Text.PrettyPrint as PP > > main = putStrLn . PP.render . toPPDoc $ tableFromCells cells > cells = [["mee","mah","moh"],["fee","fah","foh"]] > > -- This does generate an html table, but seems horribly obfuscated. > -- is there machinery for doing things like html table generation > -- in some better way than this hack where </end><start> > -- tags are used as a separator? > -- I would imagine something like > -- newSTMP "$cells:{<td>$it$</td>}:{<tr>$it</tr>}:{<table>$it</table>}" > -- which works a bit like a list comprehension > tableFromCells cells = setAttribute "cells" cells . optInsertTmpl > [("separator","</td><td>")] > $ newSTMP "$cells:\ > \{<tr><td>$it$</td></tr>}:\ > \{<table>$it$</table>}$"
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe