[stringtemplate-interest] Problem with .stg files

Bob citibob at comcast.net
Sat May 3 11:49:09 PDT 2008


Hello,

I am new to StringTemplate, so maybe this is addressed.  But I could not
find any solution...

I set up a String Template Group (see below).


Then I tried to access it as follows:

	// Get the StringTemplate...
	InputStream in =
SummaryReport.class.getClassLoader().getResourceAsStream("offstage/reports/summary.stg");
	StringTemplateGroup stg = new StringTemplateGroup(new
InputStreamReader(in));
	in.close();
	StringTemplate st = stg.getInstanceOf("summary");

But when I tried to use the resulting string template, the parser chokes
on the first "/" character in summary.  What am I doing wrong?  Does
this kind of summar group just not work for HTML templates?

I ultimately switched to putting one template per file (.st files
instead of .stg files), and it now works.

Thanks,
-- Bob

===================================================================

group summaryGroup;

summary(person,phones) ::= <<
<ul>
<li>Name: $person.firstname$ $person.lastname$</li>
<li>Email: $person.email$</li>
</ul>


<h3>Phones</h3>
<table border=1>
$phones:{
  <tr>
    <td>$it.type$</td><td>$it.number$</td>
  </tr>
}$
</table>
>>






More information about the stringtemplate-interest mailing list