Tina Müller > HTML-Template-Compiled-1.000_001 > HTML::Template::Compiled::Plugin::NumberFormat

Download:
HTML-Template-Compiled-1.000_001.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  2
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

HTML::Template::Compiled::Plugin::NumberFormat - Plugin for formatting numbers, bytes in templates

SYNOPSIS ^

    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;

DESCRIPTION ^

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;

METHODS ^

register

gets called by HTC

format_number

calls $number_format->format_number

format_bytes

calls $number_format->format_bytes

format_price

calls $number_format->format_price

syntax highlighting: