[stringtemplate-interest] How to fill a <table> grid wise?
Harry
harry.karadimas at hmn.aphp.fr
Thu Oct 11 07:05:18 PDT 2007
Hi,
How about :
<table>
<tr>
$items : mycell(a=it), mycell(a=it), mycell(a=it,lc="true")$
</tr>
</table>
----------------------- mycell.st ---------------
<td>$a$</td>
$if(lc)$ $!-- is this the last cell of the row ? --!$
</tr><tr>
$endif$
I do admit it's a bit awkward.
--------------
> I think the easiest thing to do is change the program generating the data to
create a list of lists.
>
> In JSON format the data would look like this
> {"mat": [ [ 0, 1, 2], [3, 4, 5], [6, 7, 8] ]
> }
>
> Here are the templates to process it:
> group matrix;
>
> main() ::= <<
> $table(t=mat)$
> >>
> table(t) ::= <<
> <table>
> $t:{<tr>
> $row(it)$
> </tr>}$
> </table>
> >>
> row(r) ::= <<
> $r:{<td>$it$</td>}$
> >>
>
> ---- Original message ----
> >Date: Wed, 10 Oct 2007 16:58:02 -0700
> >From: StoreAdmin <webmaster at storeadmin.com
<http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest> >
> >Subject: [stringtemplate-interest] How to fill a <table> grid wise?
> >To: stringtemplate-interest at antlr.org
<http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest>
> >
> >Hi,
> >
> >I want to fill items into a table grid-wise: i.e. 3 items per row. The
> >closest solution I can think of is as following:
> >
> ><table>
> >$items : {
> > $if (i % 3 = 1)$ <tr> $endif$
> > <td> $it:item_tmpl()$ </td>
> >$if (i % 3 = 0)$ </tr> $endif$
> >}
> ></table>
> >
> >which needs a mod(%) expression.
> >
> >Is there another way to accomplish this without modifying the ST grammar?
> >_______________________________________________
> >stringtemplate-interest mailing list
> >stringtemplate-interest at antlr.org
<http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest>
> >http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
Harry Karadimas
______________________________________________________________________
Dr Harry Karadimas Medecin Ingenieur
resp. Recherche et Developpement, Administration Wintel
Departement d'Information Hospitalier (DIH)
C.H.U. Albert Chenevier - Henri Mondor
51, av. du Marechal de Lattre de Tassigny 94010 CRETEIL
tel : (00 33 1) 49 81 21 79 fax : (00 33 1) 49 81 27 08
secr.: (00 33 1) 49 81 23 82 m.el.:harry.karadimas at hmn.aphp.fr
More information about the stringtemplate-interest
mailing list