Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Template::Alloy, which should be a drop in replacement for Template::Tookit, has a configuration option called CALL_CONTEXT that can be set to one of smart (default), item, or list. There are many ways you can change the context you call in, you can set the global CALL_CONTEXT option during new, you can set it locally using a [% CONFIG CALL_CONTEXT => "list" %] inside your template, or you can use the @() and $() context specifiers (as in [% results = @( myobj.mymethod() ) %]).

The following is a table of what is returned in each context copied from the Template::Alloy pod.

       return values      smart context   list context    item context
       -------------      -------------   ------------    ------------
    A   'foo'              'foo'           'foo'         'foo'
    B   undef              undef           undef         undef
    C   (no return value)  undef           []              undef
    D   (7)                7               7             7
    E   (7,8,9)            7,8,9         7,8,9         9
    F   @a = (7)           7               7             1
    G   @a = (7,8,9)       7,8,9         7,8,9         3
    H   ({b=>"c"})         {b=>"c"}        {b=>"c"}      {b=>"c"}
    I   (1)              1             [1]           1
    J   (1,2)          [1,2]       [1,2]       2
    K   7,8,9            7,8,9         [7,8,9]       7,8,9
    L   (undef, "foo")     die "foo"       undef, "foo"  "foo"
    M   wantarray?1:0      1               1             0

Disclaimer: I am the author.

my @a=qw(random brilliant braindead); print $a[rand(@a)];

In reply to Re: Template Toolkit 2 strange behaviour by Rhandom
in thread Template Toolkit 2 strange behaviour by Aramis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-25 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found