[Templates] Templates : Pass perl variables to BLOCKS
Mihai Bazon
mihai at bazon.net
Tue Oct 16 17:16:53 BST 2007
Since you're in a PERL block anyway, I believe it's better and cleaner
to just call $context->process instead of inserting TT code, i.e.:
print $context->process('test', { funArg => \@arr });
Not sure if it helps thought, but it should. ;-)
-M.
On Tue, 2007-10-16 at 22:27 +0630, Madan kumar nath wrote:
> Hi All,
> Is there a way to pass perl variables to BLOCKS's ?. The
> following code gives "Null Argument passed to function" and
> the value, which I am trying to get from $context is also
> coming NULL.
>
> [% PERL %]
>
> my @arr = ("hello", "madan", "kumar");
> $context->stash->set('funArgValue',\@arr);
> my $yy = $stash->get('funArgValue');
> my @yy = @$yy;
> print "\nValue in main : @yy\n";
>
> [%# Function Call %]
> [% PROCESS test funArg=funArgValue %]
>
> [% END %]
>
> [% BLOCK test %]
> [% IF (! funArg)%]
> print "Null Argument passed to function";
> [% END %]
>
> [% PERL %]
> my $yyy = $context->stash->get('funArgValue');
> print "\nValue in function: $yyy\n";
> [% END %]
>
> [% END %]
>
> Thanx in Advance
> Madan Kumar Nath
>
> _______________________________________________
> templates mailing list
> templates at template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates
>
More information about the templates
mailing list