On 6/15/07, Martin Moss <[EMAIL PROTECTED]> wrote:
Hi,

Was wondering if there is an easy way to format a
number in template toolkit to pad each 1000 withn a
comma..

e.g 1000 become 1,000   and 1000000 becomes 1,000,000

Have a read of the Template::Manual::VMethods and look for the 'chunk' method.

[% number.chunk(-3).join(',') %]

If that is too cryptic for your templates, then have a look at the
Template::Plugin::Comma plugin which also does the trick:

[% USE Comma %]
[% number | comma %]

If i18N is important to you, then look at
Template::Plugin::Number::Format which knows what convention to use
for different countries:

[% USE Number.Format %]
[% number | format_number %]


Cheers,

Cees

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to