4.5. attr-list

This tag is intended for use within embedded perl rather than as a standalone tag within a template (i.e., the [attr-list ...] syntax does not apply).

The $Tag->attr_list($template, $hashref) usage provides a shorthand for accessing values of a hash within embedded perl. It also allows you to control defaults or set up conditional values.

4.5.1. Summary

    $Tag->attr_list($template, $hashref)
Parameters Description Default
Attributes Default
interpolate No
reparse Yes
Invalidates cache no
Container tag NA (Though the template is technically body text)
Has Subtags No
Nests No

Tag expansion example (ASP-like Perl call):

    [perl tables=products]
        my %opt = ( hashref => 1,
                 sql     => 'select * from  products', );

        my $ary_of_hash = $Db{products}->query(\%opt);

        my $template = <<EOF;
            {sku} - {description} - {price|Call for price}
            {image?}<IMG SRC="{image}">{/image?}
            {image:}No image available{/image:}
            More body Text here

        foreach my $ref (@$ary_of_hash) {
            $out .= $Tag->attr_list($template, $ref);
        return $out;
     os28113 - The Claw Hand Rake - Call for price
     <IMG SRC="/mycatalog/images/os28113.gif">

     More body Text here
     os28006 - Painters Brush Set - 29.99
     No image available

     More body Text here

4.5.2. Description

Tags an attribute list with values from a hash. Designed for use in embedded Perl.

Tags according to the following rules: {key}

Inserts the value of the key for the reference. In a database query, this is the column name. {key|fallback string}

Displays the value of {key} or if it is zero or blank, the fallback string (i.e., default). {key true string}

Displays true string if the value of {key} is non-blank, non-zero, or displays nothing if the key is false. {key?} true text {/key?}

Displays true text if the value of {key} is non-blank, non-zero, and nothing otherwise. {key:} false text {/key:}

Displays false text if the value of {key} is blank or zero, and nothing otherwise. hash

This is the hash reference whose keys will be expanded within the template (see above).