Re: [htmltmpl] inconsistent file_cache behavior
Brought to you by:
samtregar
From: Mathew R. <mat...@re...> - 2004-05-17 06:07:36
|
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 -----=20 From: "Nishikant Kapoor" <nk...@we...> To: "T Mailing List" <htm...@li...> 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: > >=20 > >>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. > >=20 > >=20 > > 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(). >=20 > Okay, here is what I think is happening. >=20 > index.shtml: > ... > <!--#exec cgi=3D"/cgi-bin/featuredLinks.cgi"--> > ... >=20 > When you login or logout, sub showHome() is called. >=20 > sub showHome { > ... > my $filter =3D sub { > my $textRef =3D shift; >=20 > my $strToReplace =3D 'featuredLinks.cgi'; > if ($$textRef =3D~ /(.*cgi=3D\")(.*$strToReplace)(\".*)/) { > my $strToReplaceWith =3D &getFeaturedLinks; > $$textRef =3D~ = s/(.*cgi=3D\")(.*$strToReplace)(\".*)/$strToReplaceWith/g; > } > }; >=20 > my $template =3D HTML::Template->new(filename =3D> 'index.shtml', > file_cache =3D> 1, > file_cache_dir =3D> 'tmplCache', > file_cache_dir_mode =3D> 0777, > filter =3D> $filter); > ... > } #end of showHome() >=20 > When file_cache is ON, template is being returned from the cache,=20 > thereby bypassing the $filter which is actually responsible for = getting=20 > the appropriate data based on user's login status and hence, the=20 > inconsistency. Does this look like what is going on here? If so, what=20 > would you suggest be the workaround? >=20 > Thanks, > Nishi >=20 >=20 >=20 > ------------------------------------------------------- > 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=3D2562&alloc_id=3D6184&op=3Dclick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |