[stringtemplate-interest] Controlling the width of a string
Russell Lear
rrlear at gmail.com
Sun Jul 22 07:30:43 PDT 2007
On 7/21/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>
>
> On Jul 21, 2007, at 11:45 AM, Russell Lear wrote:
>
> > Hi,
> >
> > I've been using string template to help produce various DB reports,
> > easily changing between csv, xml and simple text formats, just
> > changing my configuration file. Cool.
> >
> > But someone asked if I couldn't make the text formatted reports
> > "prettier", by better aligning things, particularly numbers. Is it
> > possible to ask that a value occupy at least n characters? (right-
> > justify would also be nice). Is this not in the spirit of
> > StringTemplate? If it isn't could someone clear this up for me?
> >
>
> Howdy. Try wrapping strings in renderer objects whose toString() does
> what you want.
>
> Latest build also has a format option; I think John Snyders was
> working on the doc for it.
>
> Ter
>
As you say, I could wrap things with appropriate ToString() methods, but
then I miss some of the flexibility that comes with the idea that "Only
templates know what the output should look like." I could provide the
wrapper objects with configurable formatting info, but that's another
complication, especially if something more is coming Real Soon Now.
I'll watch this space for news!
Russell.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070722/ea82ac58/attachment.html
More information about the stringtemplate-interest
mailing list