On 9/27/05, Sergey Martynoff <[EMAIL PROTECTED]> wrote:
I got the impression that what he was originally trying to do was in the other direction--to hide the fact that it was in a block from the wrapper, passing the sidebar stuff in to bigtable.tt as a single variable. Like this (note that I've changed a few things to reflect what I think he was trying to do, which would be to define main content and sidebar in main.tt and then wrap that content with a table in bigtable.tt. Also, I used a macro definition in main.tt to make the calling of the wrapper as much like his original idea as possible. In other words, I think that he named the block when what he really wanted was a variable name he could easily use to pass around the contents of the block.):
--main.tt--
[% MACRO mysidebar BLOCK %]
sidebar stuff here
[% END %]
...
[% WRAPPER bigtable.tt sidebar=mysidebar %]
here is my main content
[% END %]
--bigtable.tt--
<table>
<tr>
<td>[% content %]</td>
[% IF sidebar %]<td>[% sidebar %]</td>[% END %]
</tr>
</table>
To be correct, Mark needs to quote block name when passing
parameters to WRAPPER:
[% WRAPPER bigtable.tt sidebar = 'mysidebar' %]
In this case the sidebar variable contains literal name, so block
should be called as Jason said:
[% PROCESS $sidebar %]
I got the impression that what he was originally trying to do was in the other direction--to hide the fact that it was in a block from the wrapper, passing the sidebar stuff in to bigtable.tt as a single variable. Like this (note that I've changed a few things to reflect what I think he was trying to do, which would be to define main content and sidebar in main.tt and then wrap that content with a table in bigtable.tt. Also, I used a macro definition in main.tt to make the calling of the wrapper as much like his original idea as possible. In other words, I think that he named the block when what he really wanted was a variable name he could easily use to pass around the contents of the block.):
--main.tt--
[% MACRO mysidebar BLOCK %]
sidebar stuff here
[% END %]
...
[% WRAPPER bigtable.tt sidebar=mysidebar %]
here is my main content
[% END %]
--bigtable.tt--
<table>
<tr>
<td>[% content %]</td>
[% IF sidebar %]<td>[% sidebar %]</td>[% END %]
</tr>
</table>
--
Sergey Martynoff
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]] On Behalf Of
> Jason Gottshall
> Sent: Wednesday, September 28, 2005 1:42 AM
> To: [email protected]
> Subject: RE: [Templates] Passing a BLOCK to another template?
>
> You've already passed the name of the block to your wrapper, so
just
> process it by name:
>
> --bigtable.tt--
> <table>
> <tr>
> <td>foo</td>
> [% IF sidebar %]<td>[% PROCESS $sidebar %]</td>[% END %]
> </tr>
> </table>
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates
