2009/11/4 Felipe Gasper (cPanel) <[email protected]>:
> Quoth Dermot on 11/4/2009 7:03 AM...
>
>> LID=[% userid %] # This appears correct (EG 1234)
>> interpolated=[% $userid %] # This is empty.
>> interpolated=[% ${user.id} %] # This is empty.
>>
>> <a href="[% subs.makeUserLink(userid=>$userid )">
>>
>> I can't seem to get the userid variable interpolated within the call
>> to subs.makeUserLink() . $userid is empty. I can't see where I am
>> going wrong. Can anyone offer any hints?
>
> What it seems like you want is:
>
> LID=[% userid %] # This appears correct (EG 1234)
> interpolated=[% userid %]
> interpolated=[% user.id %]
>
> <a href="[% subs.makeUserLink( { 'userid' => userid } ) %]">
Thanks for coming back to me. Unfortunately that's not working for me
either. I tried enclosing them keys/values pairs in {} but that didn't
change matters. I am attempting to send my subroutine some named
parameters but they are not getting passed through. Some form of hash
is reaching the subroutine but the variables are not there according
to Data::Dumper.
I have used $ with reference to
http://template-toolkit.org/docs/manual/Variables.html#section_Variable_Interpolation
but if I mis-reading the docs please let me know.
I've tried to make a small test case that is closer to what I am actually doing.
TT::render(
'lightbox/test',
{
lightbox => {
lid => '69264',
perpage => '12',
},
subs => {
makeLink => \&MyApp::Lightbox::makeViewOptions,
},
})
----- 'lightbox/test.tt' -----------
<ul>
[% lid = lightbox.lid %]
[% pps = [12 24 48 96] %]
[% USE iterator(pps) %]
[% FOREACH p = iterator %]
[% IF lightbox.perpage == p %]
<li><strong>[% p %]</strong></li>
[% ELSE %]
<li><a href="[% subs.makeLink(lid=>${lightbox.lid}, perpage=>$p)
%]">[% p %]</a></li>
[% END %]
[% END %]
</ul>
-------------------------
---- output -----------
<ul>
<li><strong>12</strong></li>
<li><a
href="/lightbox/lightbox.html?lid=&perpage=12&view=1">24</a></li>
<li><a
href="/lightbox/lightbox.html?lid=&perpage=12&view=1">48</a></li>
<li><a
href="/lightbox/lightbox.html?lid=&perpage=12&view=1">96</a></li>
</ul>
-----------------------
The perpage=12 is a default from the subroutine.
I suspect that I am missing a trick with subroutine references here.
Can anyone spot my mistake?
TIA,
Dp.
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates