Search code examples
perlcatalysttemplate-toolkit

sprintf function in Perl catalyst template


Currently when I add this code

[%mortgage.amortization_period%]

it gives me output as 250000.00 But I need to remove that decimal points from there. Some times I need to remove only 1 digit after decimal point. So is there any function like sprintf that I can use inside Catalyst template.


Solution

  • Sure, the function like sprintf is sprintf. You can put functions in the stash and call them from TT, and if you want them to be available all the time you can add them to the TEMPLATE_VARS in your view.