[Templates] Extending Template::Provider
Dominic Malolepszy
dmalopsy@alpha.net.au
Sat, 14 Oct 2006 21:21:20 +1000
Ended up figuring this out. I just had to pass a INCLUDE_PATH to the
default provider I was creating. Anyway, now that I'm using my own
instantiated providers, when the files do not exist no errors are thrown
to the screen that it cannot find the files. Is theres something that I
need to pass to enable it. Because if you do not create your own
Provider object and let Template create its own, than if you try to load
non-existant templates than the appropriate error is displayed. However
when you try to manually load Template::Provider this does not happen,
strange. I might be missing something :(
Anyway I got it so that templates are loaded from a database and it
appears to work :). At the moment the module I have is pretty primitive,
but I will share it here if anyone is interested, its not overly
complicated.
Cheers,
Dominic.
Dominic Malolepszy wrote:
>
> I wanted to create my own Provider in order to load templates from a
> database instead of using files. After reading bits and piece, I wrote
> a minimalist Provider just to test if it would work. Anyway it didn't :(
>
> My existing file templates simply stopped loading after using the
> custom provider, so I decided to test whether loading the standard
> provider instance would work, and I got the same result.
> I tried doing the following:
>
> my $template = new Template({
> LOAD_TEMPLATES => [
> Template::Provider->new(),
> ],
> INCLUDE_PATH => './templates',
> INTERPOLATE => 1,
> DEBUG => 1,
> });
>
> so basically if I try to load my own instance of Template::Provider it
> stops serving templates from ./templates, it doesn't even throw any
> errors that it cannot find the files etc.
> Also I tried enabling the DEBUG => 1 flag when creating my Template
> object, however where does the debug info get printed too?
> Any suggestions/help would be greatly appreciated.
>
> Cheers,
>