[stringtemplate-interest] Output string lengths..

Caleb Lyness caleb.lyness at ezswitch.net
Mon Dec 11 10:14:51 PST 2006


John Snyders wrote:
> Now that we have the format option you could do
>
> $d1;format("pad,20")$, $d2;format("pad,30")$
>
> and let the render grab the width from the format name but this is ugly.
>   
The format specifier is sufficient for doing padding:

c.f: java.util.Formatter

Here is an example:

        System.out.println("result="+String.format("|%-50s|", "hello"));
        System.out.println("result="+String.format("|%50s|", "hello"));

Output
result=|hello                                             |
result=|                                             hello|

Cheers
     Caleb



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20061211/26707e15/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3269 bytes
Desc: S/MIME Cryptographic Signature
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20061211/26707e15/attachment-0001.bin 


More information about the stringtemplate-interest mailing list