[stringtemplate-interest] ST4 - $ delimiters

Adrian Cuthbertson adrian at braidquest.co.za
Sat Jan 23 07:00:05 PST 2010


Hi,

I'm just experimenting with ST4 which I'd like to use for generating some html.
What is the correct way of changing the delimiter to a $? I tried the
following...

public class G {
	public static STGroup getG() {
		STGroup g = new STGroup();
		g.delimiterStartChar = '$';
		g.delimiterStopChar = '$';
		return g;
	}
	public static void main(String[] args) {
		STGroup g = G.getG();
		g.defineTemplate("t", "Hello $name$!");
		ST t = g.getInstanceOf("t");
		t.add("name","Fred");
		t.add("name","Blogs");
		System.out.println(t.render());
	}
}

But I get "Hello $name$!" as output.

Thanks for any assistance!

Regards, Adrian.


More information about the stringtemplate-interest mailing list