[stringtemplate-interest] ST4 Newbie - some basic questions around template complexity, localization

Henning Verbeek hankipanky at gmail.com
Wed Aug 31 02:46:15 PDT 2011


Dear StringTemplate community,

I have the wonderful task of enabling a new JEE6 web service to send
out nice emails to subscribers. It seemed natural to me to try to
separate three core concerns:
- design, layout, pretty looks --> to be owned by graphics / marketing guys
- localization --> involves texters and translators
- model, controller, logic --> done by the engineer

My desired approach was like this:
1) designer to draws up a pretty email with text elements, sample
data; produces HTML file (and related artifacts)
2) engineer separates HTML file into template, fixed strings (for
localization) and model/controller
3) the designer can still open up and edit the template (to a degree)
to adapt / change it

Not having had any experience in either Velocity, FreeMarker or
StringTemplate, I followed recommendations of "simplicity" and "best
separation of concerns" and started using ST4. So far, it's been a
rocky start, unfortunately, and I am wondering what I'm doing wrong
(or if it's supposed to be like this).

Firstly, I have not noticed any specific support for localization. We
are preferring GNU Gettext, because of its toolchain and workflow when
involving external translators. So far, I've been filling fields in
the template with st.add("someField", i18n.tr("Original string {0}",
someVariable)). Works, but maybe there is a better approach?

Secondly, and this is a *real* struggle for me: The syntax of the
template files appears to me so complex that I cannot give this out to
a graphics designer / marketing person! No CR/LF allowed, need to
prefix a template with formal arguments, etc. I'm struggling with the
statement 'templates, which are really just "documents with holes"' --
to me it seems more like yet another DSL, which a graphics designer
won't be able to understand.
Looking at the documentation, it seems that maybe StringTemplate 3 is
a better fit for me... could that be?

Please allow me to apologize for this blunt email. A lot of people
seem to be very happy with StringTemplate, and a lot of people seem to
use it to generate HTML pages. I want to be one of them, at the moment
I'm struggling with that!

Thanks for your help!
Cheers,
Hank

--
http://www.pray4snow.de


More information about the stringtemplate-interest mailing list