[stringtemplate-interest] Ok, I'm stumped

Terence Parr parrt at cs.usfca.edu
Mon Aug 6 11:34:29 PDT 2007


On Aug 6, 2007, at 9:24 AM, Barnes, Jeff wrote:

> True dat... This code better illuminates the problem. I guess I  
> better go back and revise some unit tests... ;-)
>
> import org.antlr.stringtemplate.StringTemplate;
>
> public class Test
> {
>      static class Form {
>          String[] names;
>          boolean[] values;
>          public String[] getNames() { return names; }
>          public boolean[] getValues() { return values; }
>      }
>
>      public static void main(String[] args)
>      {
>          Form f = new Form();
>          f.names = new String[] { "Terence", "Parr" };
>          f.values = new boolean[] { false, true };
>
>          StringTemplate st = new StringTemplate(
>              "$form.names,form.values:{ name, value |\n" +
>              "$name$\n" +
>              "$value$ " +
>              "$if(value)$I'm True$else$I'm False$endif$" +
>              "};separator=\"\n\"$");
>          st.setAttribute("form", f);
>          System.out.println(st.toString());
>      }
> }

Hi GUys!

Hmm...does

$form.values:{v|...}$

work?  If so, then it's an issue with the parallel walking thingie.   
Let me know; i'll add  abug.

Ter


More information about the stringtemplate-interest mailing list