HTML::Template::Compiled::Plugin::NumberFormat - Plugin for formatting numbers, bytes in templates
use HTML::Template::Compiled::Plugin::NumberFormat; my $plugin = HTML::Template::Compiled::Plugin::NumberFormat->new({ formatter => Number::Format->new(...), }); my $htc = HTML::Template::Compiled->new( plugin => [$plugin], ... ); my $out = $htc->output; $plugin->formatter($another_number_format_object); $out = $htc->output;
This plugin implements escapes ("filters") for easy use and tag names if you need more arguments.
use HTML::Template::Compiled::Plugin::NumberFormat; my $plugin = HTML::Template::Compiled::Plugin::NumberFormat->new({ formatter => Number::Format->new(...), }); my $htc = HTML::Template::Compiled->new( plugin => [$plugin], scalarref => \<<"EOM", number with different precision than the one set in the object: <%format_number .nums.big_dec precision=3 %>
escapes using the object settings: <%= .nums.big escape=format_number %> <%= .nums.price escape=format_price %> <%= .nums.bytes1 escape=format_bytes %> <%= .nums.bytes2 escape=format_bytes %> <%= .nums.bytes3 escape=format_bytes %> EOM ); $htc->param( ... ); print $htc->output;
gets called by HTC
calls $number_format->format_number
calls $number_format->format_bytes
calls $number_format->format_price
To install HTML::Template::Compiled, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Template::Compiled
CPAN shell
perl -MCPAN -e shell install HTML::Template::Compiled
For more information on module installation, please visit the detailed CPAN module installation guide.