[Templates] Newbie question about setting site wide variables

Stuart Johnston saj at thecommune.net
Mon Apr 28 21:19:24 BST 2008


David Favor wrote:
> I'm trying to set a site wide dynamic variable date similar to:
> 
>     [%
>        email     = 'someone at somewhere.com'
>        this_year = [% date.format(date.now,'%Y') %]
>     %]
> 
> Let me know the best way to dynamically assign the current year
> to a variable prior, to processing any templates.

How about something like:

In perl:

use DateTime;
$template->process($file, {now => DateTime->now});

In template:

[% now.year %]

Of course, TIMTOWTDI.



More information about the templates mailing list