[stringtemplate-interest] leading/trailing whitespace trimmed

Zenaan Harkness zen at freedbms.net
Wed Apr 16 09:16:14 PDT 2008


On Wed, Apr 16, 2008 at 10:07:43PM +0800, brian wrote:
> On Wed, Apr 9, 2008 at 2:01 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
> >
> >  On Apr 8, 2008, at 2:58 AM, brian wrote:
> >
> > > I think org.antlr.stringtemplate.StringTemplate(java.lang.String
> > > template) is trimming leading and trailing whitespace. Is it? Should
> > > it? I see a note about ST doing that for file input, but why to
> > > Strings?
> > >
> >
> >  Hi. It does it for all templates even those specified with "...".  Easier
> > to add whitespace later than to get rid of whitespace.
> 
> OK. But it'd be nice if there were a "I really mean for you to use
> this exact template, don't mess with it" flag. In fact, I really think
> producing what I told it to produce should be the default, and
> automatic whitespace removal should be an option. Thanks.

I've been using StringTemplate weekly for the past 6 months, and just
yesterday I got bitten by this trimming issue once again.

What I find frustrating is that it seems as though it can trim one OR
two newlines.

The first newline eaten, at least for <<, >> style templates (in group
files I'm using here), is forgivable - so that the layout makes sense.
But to consume the second blank line is unforgiveable. The 'solution' is
to insert <\n>, but then the problem is that sometimes (may be every
time), when at the start (or may be end, or may be both) of a template,
I get TWO empty lines where I only want one!!

At the least, there should be a specification for how to get NO lines,
how to get ONE (blank) line, and how to get more than one, blank line.
It seems horribly loose at the moment.

I might just not be understanding it properly, but it has frustrated me
on a few occasions now.

So, here's my vote for clarification, and precision. With templates it
must be possible to get precise output, per specification.

Zen

-- 
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.


More information about the stringtemplate-interest mailing list