[stringtemplate-interest] multivalue checking
Kay Roepke
kroepke at dolphin-services.de
Thu May 25 13:25:44 PDT 2006
On 25. May 2006, at 22:13 Uhr, John RW wrote:
> So it boils down to checking if any of the attributes has certain
> value. I don't know how to do that in stringtemplate.
Depending on the template lexer you use (if you don't know, it's the
one with the $-signs ;)) you can do this:
classDump:/tmp kroepke$ cat ST.java
import org.antlr.stringtemplate.*;
public class ST {
public static void main(String[] args) throws Exception {
StringTemplate st = new StringTemplate("foo ::= \"$if(foo)
$foo exists$else$foo is fubar$endif$\"");
st.setAttribute("foo", null);
System.out.println(st.toString());
}
}
In other words: use $if(namespace)$namespace is not null$endif$ to
check for a value.
HTH,
-k
More information about the stringtemplate-interest
mailing list