Hi gentlemen,

I've already sent this question to your reflexion, but no solution yet.

So, my problem and how I thought I can solve it:

The system we've built use a directory as template repository, and as a
feature, some template can be added to the sytem to add functionalities, but
not in the same directory;
e.g

the system templates
/system/templates/*.tmpl

the user templates
/user/templates/*.tmpl

my $oTemplate= new Template({
                'INCLUDE_PATH'          => [ '/user/templates/',
'/system/templates/'],
                'ABSOLUTE_PATHS'        => 0,
                'COMPILE_EXT'           =>  '.ttc',
                'COMPILE_DIR'           =>  '/system/templates/files/ttc',
        });


See the paths order on INCLUDE_PATH. This allow TTK to look before in the
user dir and after to the system dir.
Of course, system templates can be overriden, but this is not really the
feature which is interesting;
I really want the user to be able to add tmpl, BUT not in the system.

So, now, in one of my system template, I want to look in the user dir, see
if a tmpl exists, process it or process a system tmpl if none's found.

So, my system template looks like:
[%
    TRY;
        PROCESS "userTemplateNameWhichCanBeNotFound.tmpl";
    CATCH file;
        PROCESS "systemTemplateAlwaysFound.tmpl";
    END;
%]

So here, I try to process the template
"userTemplateNameWhichCanBeNotFound.tmpl", and if there is not such tmpl,
the "systemTemplateAlwaysFound.tmpl" is processed.

ok, I could add a function to my template which will be something like { -e
$file }, but I thought of the TTK cache.....
Instead of a heavy "stat", TTK can be faster... Dunno really, just a smart
guess :-/ !?

Back to the TRY / CATCH.

The previous template give me :
file error - userTemplateNameWhichCanBeNotFound.tmpl: not found at
/usr/lib/perl5/site_perl/5.6.0/Template/Context.pm line 499.
undef error - [Thu Aug  9 13:05:18 2001]  31602 null ERR: file error -
userTemplateNameWhichCanBeNotFound.tmpl: not found at
/usr/lib/perl5/site_perl/5.6.0/Template/Context.pm line 499.
seen on my browser and the same in the error log.FYI, I'm using perl 5.6.0 &
TTK 2.04 & Apache 1.30.20 & modperl 1.25.What did I miss ?How can I REALLY
catch the error ? Avoid the output to stderr ?Is it the correct way to do it
?Any help are welcome.kktos






Reply via email to