From: "Sam Tregar" <[EMAIL PROTECTED]>
> Are you sure it needs to happen "only once"? Your example doesn't
> support that meaning. In your example the language-specific stuff
> needs to change when the language changes.
Sam. First, thank you for your consideration.
I only load a template for a language once. When I load it I perform all the
one-time language-specific value replacements. Otherwise I'd have to keep a
language-specific copy of the template in directory structures and "new" the
template from the correct structure. I used to do this. But now I prefer
keeping all the language specifics in Locale::Maketext and do a one-time
replacement of template values which heretofore had been kept in
language-specific templates.
The psuedo-code looks like this:
==============
if (!exists($template_hash{$visitor_language})) {
template->new(template-path/name)
$maketext_languageHandle_hash{$visitor_language} =
Locale::Maketext->get_handle($visitor_language);
initialize_language_specific($template-hash{$visitor_language},
$maketext_language_handle_hash{$visitor_language});
}
===============
Inside "initialze_language_specific" I do *not* evaluate *everything* in the
template. There are some things that are specific to each display of the
page. So, that's done with each re-display.
Two problems with this mechanism are:
1. I'm effectively caching my own template so I can keep the one-time
evaluations across multiple displays.
- Now I have to add my own test of whether a template has changed. An
unwelcome movement of functionality in H::T into my domain. :)
- If I had concerns about how much memory I was consuming and/or how long
I keep a little-used template in memory, I have to build this into my logic.
2. My self-cached template's state is exactly as last output'ed. I can't
take for granted that default (think TMPL_ELSE) evaluations have their
default values. I always have to perform all evaluations (other than the
ones I did in the initialize).
To me this seems like something that could be useful to all H::T users. It
seems like it wouldn't burden H::T to have the option to specify that
evaluation be performed on the cached copy of the template?
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users