[Templates] Defining MACRO as a subroutine

[prev] [thread] [next] [Date index for 2004/04/29]

From: Gernot Homma
Subject: [Templates] Defining MACRO as a subroutine
Date: 11:16 on 29 Apr 2004
Hello everybody,

is there a way to implement macros as subroutines ?
what i want to do is the following:

my $template = new Template({
   PRE_DEFINE => {
      exec => \&myexec
   }
});

sub myexec {
   my $context = shift;
   my $stash = $context->stash();
   # do some stuff here and set variables in $stash
}

in my template i have the following definitions:
[% MACRO exec INCLUDE exec %]
[% exec(name = 'mythingtoexecute') %]

this is working fine, what i want to have is that i have not to make the
macro definition, so that in my template
[% exec(name = 'mythingtoexecute') %]

does just the same as above ... 

thanks in advance

gernot



Gernot Homma
Cyber-Atelier
Shuttleworthstr. 4-8/Objekt 50
fon: +43 1 272 92 51 6
fax: +43 1 272 92 51 9
mail: homma@xxxxxxxxxxxx.xx
 

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Defining MACRO as a subroutine
Gernot Homma 11:16 on 29 Apr 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52