Approach the problem from a slightly different tack. Don't try to do everything in one pass through H::T. Instead, think of it as a two-step approach.
Each user belongs to a group, and the group portions of the template are the same for all members of that group. Only the user portions need to change with each visit. So, separate the group variables from the user variables. In this type situation, I do a one-time "page generation" of the "group" template to be used for subsequent user visits. That user template is generated from a "master template" where all the "group" level elements (like logo image, background and text colors, etc.) are normal TMPL_VAR's to be handled during this page gen step. Portions that pertain to user-specific variables are "renamed" (or purposely misnamed, if you will) TMPL_VAR's so they are not recognized and handled by H::T during this pass. So, the user's first name, which should be "ignored" during the page gen might be in a "tag" named like - <my_special_VAR NAME=first> In my page gen code I take the output H::T and rename the dummy VAR names to "proper" H::T TMPL_VAR's before writing out the user version of the template. Assuming you've got an H::T object, $template, and previously opened FileHandle, $fh, the code would look something like this - my $output = $template->output; ## Replace temporary tags with HTML::Temlate tags before write to file # $output =~ s/my_special_VAR/TMPL_VAR/g; print $fh $output; The template output in the output file pointed to by $fh is then your "user" version of the template. All the "group-level" elements have already been replaced with the hard-coded equivalents. Makes for a much faster end-user experience since there are less tags to process at that level. Steve Ragan Sr. Internet Developer Harris Internet Services 2500 Westchester Ave. Purchase, NY 10577 Phone: 914-641-3948 Fax : 914-641-3901 [EMAIL PROTECTED] -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Mark Fuller Sent: Tuesday, January 18, 2005 12:26 PM To: HTML::Template users Subject: [htmltmpl] RFC: Persistent or 2-stage evaluation Sam, earlier I said it would be useful if I could apply some evaluation once. Then operate upon that partially evaluated template. I didn't realize H::T applies everything at output(?). If H::T applies everything at output, wouldn't it be relatively easy to accomplish this if there was a way to tell H::T to perform an "output" *but don't eliminate any H::T tags that are unevaluated*? If I could do this, I could set all my one-time page evaluation and do a "new_scalar_ref->" (using the output from my first "new->" from a file). If there were a way to tell H::T to reload it internally there may be a way to utilize H::T's caching mechanism (instead of me keeping my H::T object in %hash_of_templates{language}). Doing a "new->" would have to tell me it reloaded the template so that I could do the one-time processing again (and output_internal-> to put it back into the state where it's mostely prepared for repeated processing). What do you think? Would it be easy to do by sub-classing? Did you eventually agree there is a legitimate case for one-time page evaluation? (One-time language replacement of title, headings, navigation, etc.) I'd like to apply some heavy replacement and do it only once. Keep the resulting text containing only the tags that are evaluated on a display-by-display basis (messages, etc.). This might have some application for select/option lists too. I won't confuse the issue with that yet. My main concern is just to avoid repetitive numerous replacement of text which is constant for a page. Thanks! Mark ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users