[Catalyst] Templates in the database

Jess Robinson castaway at desert-island.demon.co.uk
Sat Jan 20 14:25:39 GMT 2007



On Thu, 18 Jan 2007, Bill Moseley wrote:

> I currently have most templates (TT) on disk -- and many I'd consider
> to be an integral part of the application and are thus under revision
> control with the rest of the application.
>
> But, it would make managing the running application a bit easier if
> the templates were in the database.  But, I don't really want to give
> up revision control.
>
> First, I'm curious if many people are serving templates from the
> database.

I have plans to do that (which went as far as writing 
Template::Provider::DBI and including it in my app), but not actually 
using yet.

> I'm also curious about methods you might use for revision management
> of the templates (or any content) that are in the database.

I assume this is some sort of CMS-like app where the users can edit 
templates/data etc? I hadn't thought of that side of it yet, but I imagine 
a decent set of auditing tables would do the trick. Give the templates 
versions, and always show the newest, or always show 1 which is live, and 
have the older ones renumbered (this is what our work system does). Or, 
have the tepmlate table itself stay clean, and have a trigger 
copy-on-update to an audit table (which keeps down the size of the most 
used table). (hmm, you said that down below, I should read more)

Our work system very crudely just shows which fields have changed, but not 
how.. annoying that.. better ways, maybe Test::Differences, which IIRC has 
a nice display to show them?

>
>
> I currently have "static content" served from the database -- but I
> haven't overridden Template::Provider, rather I fetch the template and
> pass it as a scalar ref to TT.  But, all other templates are
> still served off disk (wrappers, footers, headers, layout, etc).
>
> I do maintain a history of these pages, and I have a crude "diff" view
> using Algorithm::Diff.  I have a table that holds the history of the
> content and use triggers to write to it on update.

That sonuds like quite a sane way to do it, and how I probably would.


Jess



More information about the Catalyst mailing list