[stringtemplate-interest] basic question to template group

Terence Parr parrt at cs.usfca.edu
Mon Jul 14 13:22:34 PDT 2008


To Use a group file, you must use the StringTemplateGroup(Reader)  
constructor... it does not find groups within directories... sorry  
about that.  call the file .stg not .st also as it will be a group.
Ter
On Jul 13, 2008, at 1:42 PM, Dieter Frej wrote:

> Hi,
>
> what I wanted to do was to put all templates (all in all these are  
> around 5 templates) in one physical file and use this file to  
> generate my output. Following the great number of example on the  
> Internet, I figured that I need a template group to realize my  
> requirement
>
> StringTemplateGroup stGroup = new StringTemplateGroup("mygroup", "C:\ 
> \Users\\xyz\\workspace");
> StringTemplate st = stGroup.getInstanceOf("junit");
> st.setAttribute("tests", ts);
> System.out.println(st.toString());
>
> I created the junit.st file and placed in the directory specified in  
> the constructor of the StringTemplateGroup. In my junit.st I want to  
> call another "template method"
>
> junitclass(testheet) ::= <<
>
> public class $tests.name$ {
> 	
> 	$m23ethod(rows=tests.rows)$
> 	
> }
>>>
>
> Putting also
>
> m23ethod(rows) ::= <<
> 	public void test() {
> $rows:{ u |
> 	$u.inputColumns; separator=", "$
> }$
>>>
>
> in junit.st does not working. I get the following exception
>
> Exception in thread "main" java.lang.IllegalArgumentException: Can't  
> find template m23ethod.st; context is [junit]; group hierarchy is  
> [mygroup]
>
> Maybe I do not fully get template groups, but why am I required to  
> create a separate template for each method I am calling? Or am I  
> doing something wrong? (or totally missing the point? also  
> possible ;-)
>
> And: what does the "mygroup" (in the constructor of the template  
> group) tell me? What is it used for?
>
> Thanks in advance
>
> - Didi
>
>
> -- 
> Psssst! Schon das coole Video vom GMX MultiMessenger gesehen?
> Der Eine für Alle: http://www.gmx.net/de/go/messenger03
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list