I need a value to be rounded in the Perl's Template Toolkit. But I am not able to use ceil()
.
[%interestRate = ceil(mortgage.interest_rate / 100)%]
The answer shows a null
value.
Maybe you need division directive:
[% 15 / 6 %] -> 2.5
[% 15 div 6 %] -> 2
[% 15 mod 6 %] -> 3
The div operator returns the integer result of division. Both % and mod return the modulus (i.e. remainder) of division.
http://www.template-toolkit.org/docs/manual/Directives.html
If you prefer a CPAN module, then look into Template::Plugin::POSIX
. This module provides amongst others the ceil
and floor
functions:
[% USE POSIX -%]
[% POSIX.ceil(0.5) %]
[% POSIX.floor(0.5) %]
Output:
1
0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With