[Templates] Missing hash and MACRO assignment in docs?

darren chamberlain dlc@users.sourceforge.net
Tue, 19 Nov 2002 08:53:13 -0500


* Paul Makepeace <tt2.org@paulm.com> [2002-11-19 05:26]:
> 1.
> 
> The syntax,
> 
> [% farm = { pig => 2, sheep => 5 } %]
> 
> ..I couldn't find anywhere in the docs. In Template::Manual::Variables
> it mentions building lists but not hashes. Is this syntax supported?

Yes, it's supported.  Did you try it?

  $ tpage
  [% farm = { pig => 2, sheep => 5 } %]
  [% USE dumper; dumper.dump(farm) %]
  ^D

  $VAR1 = {
            'sheep' => 5,
            'pig' => 2
          };

Its omission from the docs is accidental.

> 2.
> 
> I discovered you can assign from MACRO foo BLOCK calls (which is great!)
> but didn't see any mention of this feature in the section in
> ::Directives on MACROs. In the BLOCKs section with the "julius = BLOCK"
> example it shows this but it strikes me this could be a bit more "out in
> the open" with some examples using conditionals, e.g.
> 
> [% MACRO twice(a) BLOCK %]
>  [% IF a > 3 %]
>   [% a+a %]
>  [% ELSE %]
>   too small!
>  [% END %]
> [% END %]
> 
> [% a = twice(2) %]
> 
> **
> 
> If I haven't missed where these are documented I'm happy to make a
> couple of .pod patches.

There are some casual mentions of the above syntax
(L<Template::Manual::Directives>, search for "MACRO header IF"), but not
as many as might be nice.

Patches are always welcome, of course.  If you grab the source from CVS,
look in docsrc/lib/dir/macros

> "What is the time in Boston? Terribly short and smelly."
>    -- http://paulm.com/toys/surrealism/

Hey, as a resident of Boston, I take offense to that...

(darren)

-- 
Things exist, they're just not there.