Re: [Templates] Templates in database

[prev] [thread] [next] [Date index for 2004/08/30]

From: Dave Cash
Subject: Re: [Templates] Templates in database
Date: 22:11 on 30 Aug 2004
On Mon, 30 Aug 2004, Dennis Daupert wrote:

> I'm trying to learn how to store my templates in a database
> and use from there. I must be missing something simple, but
> can't seem to get the variables to resolve.
>
> I have a template like:
>
> Dear [% emp_fname %]:
>
> Your application requesting an ID has been approved.
>
> If you have any questions, please contact the ID Administrator
> at [% IDAdminEmail %].
>
> Then I read it out of the database:
>
> [% query = DBI.prepare('SELECT * FROM email WHERE emailid = ?') %]
>
> [% FOREACH tmpl = query.execute('1') %]
> [% email = tmpl.body %]
> [% END %]
>
> Then I display -- just to see what he's done:
>
> <pre>[% email %]</pre>
>
> He shows me the original template, but none of the template tags
> (variables)
> are resolved.
>
> What am I doing wrong here?

Dennis,

I think you want:

 <pre>[% email | eval %]</pre>

But as Randal pointed out last week, you can't take advantage of
extremely advantageous template caching mechanism built into TT2
(via the COMPILE_DIR, COMPILE_EXT and CACHE_SIZE config options).

Dave

/L\_/E\_/A\_/R\_/N\_/T\_/E\_/A\_/C\_/H\_/L\_/E\_/A\_/R\_/N\
Dave Cash                              Power to the People!
Frolicking in Fields of Garlic               Right On-Line!
dave@xxxxx.xxx                                  Dig it all.

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Templates in database
Dennis Daupert 20:24 on 30 Aug 2004

Re: [Templates] Templates in database
Dave Cash 22:11 on 30 Aug 2004

Re: [Templates] Templates in database
Kenneth Ekdahl 06:52 on 31 Aug 2004

Re: [Templates] Templates in database
Jamie McCarthy 14:09 on 31 Aug 2004

Re: [Templates] Templates in database
Perrin Harkins 18:11 on 31 Aug 2004

Re: [Templates] Templates in database
Adam Kennedy 03:32 on 01 Sep 2004

Re: [Templates] Templates in database
Dennis Daupert 18:43 on 31 Aug 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52