[stringtemplate-interest] Problem with .stg files

Terence Parr parrt at cs.usfca.edu
Sat May 3 11:52:37 PDT 2008


group files use <...> not $...$ by default. you can switch it though.
Ter
On May 3, 2008, at 11:49 AM, Bob wrote:

> 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>
>>>
>
>
>
>
> _______________________________________________
> 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