[stringtemplate-interest] Output string lengths..
Terence Parr
parrt at cs.usfca.edu
Mon Dec 11 10:29:52 PST 2006
On Dec 11, 2006, at 10:14 AM, Caleb Lyness wrote:
> 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|
>
So, We could do the following $name; format="%50s"$, right? then
someone would have to make a string renderer, but that is easy.
Ter
More information about the stringtemplate-interest
mailing list