On Mon, 25 Jun 2001, Robin Szemeti wrote:

> for instance [% CALL useroption( cgi.param('option') ) %] is a
> function that does something and accepts a list of options .. but TT
> automatically folds the list of option returned by the cgi.param
> method into a array ref .. unless it is a list of one .. in which case
> it doesnt .. that neatly buggers up your foreach( @{$options} ){ ...}
> method in the underlying perl ... involves some if ref($options) eq
> 'ARRAY' stuff .. unless you can point me at a better way?

You could make use of the funky new .array / .hash / .item virtual
methods introduced in Template Toolkit 2.03. (see changelog
http://www.template-toolkit.org/pipermail/templates/2001-June/001097.html)

> is there an easy way to determine what class something is .. eg a
> search method that returns a list of object of different classes that
> needs different template to present them .. at the moment I set the
> name of the class in a method and do a [% IF obj.class == 'News' %] ..
> but that must be bad I think .. is there a way of determining what
> class something is like the ref() perl function ??

See the section on VIEWs.  These can do pretty much what you want (e.g.
call different BLOCKs/template files for presentation based on what an
object's class is)
http://www.template-toolkit.org/docs/default/Manual/Views.html

> I have a bit of leak when running it under mod_perl ..
> but thats me I think not TT ...and once I get that sorted it will
> be ready to go up ..

Remember to reuse the same Template object each time rather than
recreating it each time.

Later.

Mark.

(who's glad to have fast internet back again)

-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}


Reply via email to