[stringtemplate-interest] basic question to template group
Dieter Frej
dieter_frej at gmx.net
Sun Jul 13 13:42:13 PDT 2008
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
More information about the stringtemplate-interest
mailing list