- The list operator promotes scalars to lists (it's a no-op for lists),
    so you can reliably write:

        [% cgi.checkbox_group('list', fooey).list.join("\n") %]

    Although checkbox_group is still called in array context,
    the list operator saves you in the case where checkbox_group
    returns a single-element list, which TT demotes to a scalar.

  - Use the experimental stash Template::Stash::Context, which allows
    you to call plugin functions in scalar context using the new
    virtual "scalar" operator.  Here's a complete example:

        use Template;
        use Template::Stash::Context;
        use CGI;

        my $args = {
          cgi  => CGI->new,
          fooey => [qw/foo bar baz/],
        };
        my $stash = Template::Stash::Context->new($args);
        my $tt    = Template->new({ STASH => $stash });
        $tt->process(\*DATA, $args) or die $tt->error();

        __END__
        [% cgi.h1("Test") %]
        [% cgi.checkbox_group('list', fooey).scalar %]
        [% cgi.checkbox_group('list', ["abc"]).scalar %]

Craig


Reply via email to