[stringtemplate-interest] Spaces around template attributes
Steve Ebersole
steve at hibernate.org
Wed Apr 29 15:41:52 PDT 2009
I got close. I wishfully thought maybe this might work:
sortSpecification(sortKey,collationSpecification,orderingSpecification) ::= <<
<sortKey>< collationSpecification>< orderingSpecification>
>>
It just smooshed everything together
-> sortSpecification(sortKey="xyz",collationSpecification="collate abc",orderingSpecification="asc")
lead to:
xyzcollate abcasc
while
-> sortSpecification(sortKey="xyz",collationSpecification=null,orderingSpecification="asc")
gave:
xyzasc
>From the second example you can see it is doing TheRightThing WRT to the
embedded space when the attribute is undefined/null.
On Wed, 2009-04-29 at 14:33 -0700, Terence Parr wrote:
> On Apr 29, 2009, at 7:59 AM, Michael wrote:
>
> > Am Wednesday 29 April 2009 16:43:30 schrieb Steve Ebersole:
> >> I am trying to deal with extra spaces in my stringtemplate output
> >> when
> >> attribute values used within the template are null/empty. I figure
> >> this
> >> has to be a pretty common requirement, so I thought I'd ask here
> >> how to
> >> accomplish this.
> >>
> >> For example, I have a template like:
> >> sortSpecification
> >> (sortKey,collationSpecification,orderingSpecification) ::=
> >> << <sortKey> <collationSpecification> <orderingSpecification>
> >>
> >
> > you can try it with list construction, *untested* :
> >
> > sortSpecification
> > (sortKey,collationSpecification,orderingSpecification) ::=
> > <<
> > <[sortKey, collationSpecification, orderingSpecification];
> > separator=' '>
> >>>
>
> something like this seems best. almost common enough thtat we need an
> operator for that!
>
> Ter
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
--
Steve Ebersole <steve at hibernate.org>
Hibernate.org
More information about the stringtemplate-interest
mailing list