[stringtemplate-interest] Controlling the width of a string

Terence Parr parrt at cs.usfca.edu
Sat Jul 21 18:06:58 PDT 2007


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


More information about the stringtemplate-interest mailing list