The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Perlbug::Object::Template - Template class

DESCRIPTION

Applies a template to the data generated by Perlbug::Format.

Each user may apply a template to each object | type.

Defaults for a particular type of object (eg; mail, flag, ...) may be applied by enabling the type column instead of the object one.

For inherited methods, see Perlbug::Object

SYNOPSIS

        use Perlbug::Object::Template;

        my $o_tmp = Perlbug::Object:;Template->new();

        print $o_tmp->object('bug')->read('19870502.007')->template('h');

ARGUMENTS

format

See Perlbug::Format

PLACEHOLDERS

Placeholders in templates look like this: <{datacol}> and <{rel_ids}> etc.

Example using bug object:

  Column names:

        bugid:   <{bugid}>
        created: <{created}>            
        author:  <{sourceaddr}>
        subject: <{subject}>

  Relationships:

        message count(<{message_count}>)

        messageids: <{message_ids}>
        patch ids:  <{patch_ids}>
        admins:     <{user_names}>
        CC list:    <{address_names}>
        status:     <{status_names}>
        <{ifadmin}>
                this bit only if admin
        </{ifadmin}>

FORMATTING

To assist with formatting of ascii templates, an integer followed by white space may be placed between the last two special characters of the placeholders. The (internal) white space will be stripped, and the number will be used to pad out the given variable, with spaces, using sprintf to that length.

N.B. this will not trim the field, but pad it.

        bugid:    <{bugid}15    > status: <{status_names}>
        severity: <{severity_names}  15 > osname: <{osname_names}>
        messages: <{message_count}  15  > <{message_ids}>

will produce

        bugid:    19870502.007   status: open
        severity: high           osname: linux aix etc.
        messages: 5              22 23 41 72 102 

METHODS

new

Create new Template object:

        my $o_merge = Perlbug::Object::Template->new();
object2id

Return template id given current object key type and perhaps format and/or user

        my $templateid = $o_tmp->object2id('bug', ['a', ['perlbug']]);
_merge

Return catchall object data laid out against format(a).

Long lines will be wrapped - if you want a better format, define a template :-)

        my $str = $o_tmp->_merge($h_data, $h_rels);

        my $str = $o_tmp->_merge($h_data, $h_rels, [$fmt]);
merge

Return object in template layout according to format(a), relations are called from the object given.

        my ($hdr, $str, $ftr) = $o_tmp->merge($o_obj, $fmt, [\%data, \%rels]);

If no template found, calls _merge()

xtra

Add a little extra to the data, as a helper for default templates

        my $h_data = $o_tmp->xtra($key, $o_obj->oid, $h_attr);

AUTHOR

Richard Foley perlbug@rfi.net 2001

1 POD Error

The following errors were encountered while parsing the POD:

Around line 104:

=back without =over