try 'perldoc HTML::Template' then search for filter... the first thing it says is:

filter - this option allows you to specify a filter for your
               template files.  A filter is a subroutine that will be called
               after HTML::Template reads your template file but before it
               starts parsing template tags.


thus, filtering is only applied on file load (ie when the tamplate is parsed for 
tags).  Since caching wont allow the file to reload unless it changes, the filer is 
not re-applied.

To solve this, you can either:
a) disable caching if you want to keep the filter
b) re-implement the template so that you dont need to use a filter, by using TMPL_IF 
and TMPL_INCLUDE

Hope this helps,
Mathew


----- Original Message ----- 
From: "Nishikant Kapoor" <[EMAIL PROTECTED]>
To: "T Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, May 17, 2004 3:56 PM
Subject: Re: [htmltmpl] inconsistent file_cache behavior


> Sam Tregar wrote:
> > On Sun, 16 May 2004, Nishikant Kapoor wrote:
> > 
> >>I do edit the template by hand but in this case, the mtime on the
> >>template is not changing. However, the content for the template needs to
> >>change based on whether the user is logged-in or logged-out.
> > 
> > 
> > Well that has nothing to do with the file cache.  To convince
> > yourself, turn it off and observe that nothing changes!  The file
> > cache is just saving HTML::Template the trouble of loading the
> > template from disk every time it needs it.  It has nothing to do with
> > the output - that's driven by your calls to param(), which are reset
> > after every new().
> 
> Okay, here is what I think is happening.
> 
> index.shtml:
> ...
>    <!--#exec cgi="/cgi-bin/featuredLinks.cgi"-->
> ...
> 
> When you login or logout, sub showHome() is called.
> 
> sub showHome {
> ...
>    my $filter = sub {
>      my $textRef = shift;
> 
>      my $strToReplace = 'featuredLinks.cgi';
>      if ($$textRef =~ /(.*cgi=\")(.*$strToReplace)(\".*)/) {
>        my $strToReplaceWith = &getFeaturedLinks;
>        $$textRef =~ s/(.*cgi=\")(.*$strToReplace)(\".*)/$strToReplaceWith/g;
>      }
>    };
> 
>    my $template = HTML::Template->new(filename => 'index.shtml',
>                                       file_cache => 1,
>                                       file_cache_dir => 'tmplCache',
>                                       file_cache_dir_mode => 0777,
>                                       filter => $filter);
> ...
> } #end of showHome()
> 
> When file_cache is ON, template is being returned from the cache, 
> thereby bypassing the $filter which is actually responsible for getting 
> the appropriate data based on user's login status and hence, the 
> inconsistency. Does this look like what is going on here? If so, what 
> would you suggest be the workaround?
> 
> Thanks,
> Nishi
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: SourceForge.net Broadband
> Sign-up now for SourceForge Broadband and get the fastest
> 6.0/768 connection for only $19.95/mo for the first 3 months!
> http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
> _______________________________________________
> Html-template-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
>


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id%62&alloc_ida84&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to