[stringtemplate-interest] filling a field ($...$) with data that also contains a (part of) a field ($...$test)
Christophe Vanderhaeghen
christophe at soletis.be
Mon Feb 1 02:19:10 PST 2010
Hi all,
I have a template (myTemplate.st) which is filled with data from the
database.
In the database, the fields might also contain stringtemplate-fields
($...$), thus allowing in the database some dynamics as well.
What I do now is loop twice through the text where the second wave uses the
string-result from the first wave. Like this:
StringTemplateGroup group = new StringTemplateGroup("Templates",
Application.StartupPath + "/Templates/");
StringTemplate template = group.GetInstanceOf("/Module");
template.SetAttribute(GetData().GetType().Name, GetData()); //Get the data
from the database
string firstWave = template.ToString(); //Fill the fields with the data that
came from the database
//Now do it for a second time so that the dynamic items from the database
are formatted also:
StringTemplate secondWave = new StringTemplate(firstWave);
secondWave.SetAttribute(GetData().GetType().Name, GetData());
string x = secondWave.ToString();
Question: Is there an alternative way to get all fields filled at once so
that I don't have to StringTemplate twice?
Thanks in advance,
Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20100201/e52ea0c8/attachment.html
More information about the stringtemplate-interest
mailing list