Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32831

stringtemplate and STGroup

Newsgroups comp.lang.java.programmer
Date 2015-10-08 03:17 -0700
Message-ID <f78fab30-3f41-4dec-9f34-10d31f2d1261@googlegroups.com> (permalink)
Subject stringtemplate and STGroup
From sessantaquattrobits@gmail.com

Show all headers | View raw


To make a long story short:
where can i find a tutorial about stringtemplate and STGroup ?
Google and su www.stringtemplate.org hasn't been an help, for me :(

A more specific questios is:
how can I use an STG with multiple attributes/substitutions ?

I succeeded in this:

templName(param) ::= <<$param:{param | $\n$$\t$<td><a href='link'>$param$</a></td>}$ >>
corresponding java is:
final STGroup stGroup = new STGroupFile("templates/exampleTemplateTD1.stg",'$','$');
final ST templName = stGroup.getInstanceOf("templName");
templName.add("param", Arrays.asList(new String[]{"descr1", "descr2", "descr3"}));

I would like to substitute also the "link"
Many efforts leaded me to the unsatisfying:

templName(param,link) ::= <<
$param:{param | $\n$$\t$<td><a href='$link:{link|$link$}$' >$param$</a></td>}$ >>
java is:
final STGroup stGroup = new STGroupFile("templates/exampleTemplateTD1.stg",'$','$');
final ST templName = stGroup.getInstanceOf("templName");
templName.add("param", Arrays.asList(new String[]{"descr1", "descr2", "descr3"}));
templName.add("link", Arrays.asList(new String[]{"link1", "link2", "link3"}));

the poor output is:
<td><a href='link1link2link3' >descr1</a></td>
<td><a href='link1link2link3' >descr2</a></td>
<td><a href='link1link2link3' >descr3</a></td> 

TIA to who could find the time and patience to help me!

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

stringtemplate and STGroup sessantaquattrobits@gmail.com - 2015-10-08 03:17 -0700

csiph-web