Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

gav
  (email not shown publicly)
http://www.estey.com/
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Monday December 22, 2003
11:33 AM

Subclassing Template::Provider?

[ #16458 ]

I'd like to be able to serve TT2 templates from a database. The FAQ suggests that I need to subclass Template::Provider. Has anybody got a simple example of doing this? I've poked about in the source for Slash but that confused me.

On the subject of TT2, does anybody know when the book will be released?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Slashcode [slashcode.org] does this.
    --
    • Randal L. Schwartz
    • Stonehenge
  • ...at least for the introductory stuff. Looking back at the code in OpenInteract 1.x [cpan.org] it's actually pretty well commented and may give you an idea of what to do. Everyplace where it refers to a 'SiteTemplate' object just substitute 'database record'. It's a good idea to put this in an object because you may find that database access isn't all that great for your needs -- filesystems are very efficient :-)

    One note: OI has a custom Template::Context object which interprets templates with a package::name format for its own uses, so calling something like:

    [% INCLUDE mypackage::mytemplate %]

    will do the right thing ('package' in this case being an OpenInteract package, not a Perl package).

  • I did the work for it in Slash, you can pick my brain if you wish.