Re: [Templates] Stringifying objects in templates

[prev] [thread] [next] [Date index for 2004/11/10]

From: Drew Taylor
Subject: Re: [Templates] Stringifying objects in templates
Date: 01:59 on 10 Nov 2004
On Tue, 09 Nov 2004 16:46:31 -0800, Derrek Long
<derrek.long@xxxxxxxxxxxx.xxx> wrote:
> Drew Taylor wrote:
> 
> >In the template I wanted to take the stringified class_date object
> >("2004-10-25 09:00:00") and split on the white space to get the
> >individual day and hour components. My first thought was:
> >
> >  [day, time] = schedule.class_date.split(' ');
> >
> >But this tried calling the split() method on the Class::Date object
> >rather than the stringified version. So then I tried:
> >
> >  [day, time] = ${date.class_date}.split(' ');
> >
> >
> If class_date really isa Class::Date object can't you just do this?
> [%
>   date = schedule.class_date.ymd
>   time =  schedule.class_date.hms
>   day = schedule.class_date.day
> %]

That's basically what I ended up doing, along with defining some
custom methods on my Date object which use srtftime() for my preferred
formats.

Drew
        -- 
        ----------------------------------------------------------------
 Drew Taylor                 *  Web development & consulting
 Email: drew@xxxxxxxxxx.xxx  *  Site implementation & hosting
 Web  : www.drewtaylor.com   *  perl/mod_perl/DBI/mysql/postgres
 ----------------------------------------------------------------

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

[Templates] Stringifying objects in templates
Drew Taylor 14:26 on 25 Oct 2004

RE: [Templates] Stringifying objects in templates
Jason Gottshall 19:28 on 25 Oct 2004

Re: [Templates] Stringifying objects in templates
Drew Taylor 01:59 on 10 Nov 2004

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