<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>Re: [ic] more-list and interpolation</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2> On 8/17/2010 4:02 PM, Peter wrote:<BR>
> On 17/08/10 03:39, Wadkins, Raymond wrote:<BR>
>> I had a requirement to conditionally control the inclusion of<BR>
>> decade-next and decade-prev tags in a more-list. So, I blithely wrapped<BR>
>> them in an if block, then was surprised when the negative condition<BR>
>> wasn't working. Turns out that the contents of more-list aren't<BR>
>> interpolated before being processed, so the regular expression in<BR>
>> tag_more_list was matching my tags desipite their being included in an<BR>
>> if block.<BR>
>><BR>
>> I hacked a few extra lines into Vend::Interpolate (below), but I'm<BR>
>> wondering if there's something I've missed that could do this without<BR>
>> the hack?<BR>
>><BR>
>> if($r =~ s:\[interpolate\]::i) {<BR>
>><BR>
>> $r = Vend::Interpolate::interpolate_html($r);<BR>
>><BR>
>> }<BR>
> Can you give some more details about what you were originally trying to<BR>
> accomplish here? There is almost certainly a better way to do this than<BR>
> by hacking Interpolate.html, but it's hard to tell you what to do with<BR>
> so little information.<BR>
><BR>
Imagine that the scratch values are optionally set elsewhere<BR>
<BR>
[tmp has_decade]0[/tmp]<BR>
<BR>
--snip--<BR>
<BR>
[tmp body_more_links]<BR>
[more-list]<BR>
[first-anchor]none[/first-anchor]<BR>
[last-anchor]none[/last-anchor]<BR>
[next-anchor][scratch text_action_next][/next-anchor]<BR>
[prev-anchor][scratch text_action_previous][/prev-anchor]<BR>
[if scratch has_decade][decade-next][scratch<BR>
text_action_next_decade][/decade-next][/if]<BR>
[if scratch has_decade][decade-prev][scratch<BR>
text_action_links_prev_decade][/decade-prev][/if]<BR>
[scratch text_label_page]<BR>
[more]<BR>
[/more-list]<BR>
[/tmp]<BR>
<BR>
Unfortunately, what gets handed to Vend::Interpolate::tag_more_list as<BR>
the body is not interpolated, so the "if" blocks aren't evaluated and<BR>
the string "[decade-next]", when encountered by the regular expression,<BR>
turns on the decade functionality. It seems that the code is reparsed<BR>
when it's done, but by then it's too late, the functionality has been<BR>
changed.<BR>
<BR>
What I want to happen is to be able to control when the decade-based<BR>
logic occurs on a list of pages conditionally. I could achieve this<BR>
with two different more-list blocks, but I hate repeated code.<BR>
</FONT>
</P>
</BODY>
</HTML>