Mark Fowler wrote:

> 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)

OK .. I'll grab the latest ver as soon as I get back near a real connection
instead of laptop and mobile phone.


> > 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

Perfect .. why didnt I see that before doh! .. thanks ... I guess its RTFM
then ... :))

>
>
> > 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.

really? .. the documentation  ( Template::Tutorial page 10 ) says to create a
new one each time your handler{} method is called ?  ... but thanks for that
..  I did that and its better  .. (no longer grows by lots each time .. now
it jsust *occasionally* grows by 4k :) (about 1 hit in every ten on the same
page ...)

> (who's glad to have fast internet back again)
I'm missing my ISDN :( .. but the weather is great  :) .. spent most of today
floating about in a river to keep cool.

As for fast .. my last $orkplace  had a pair of Nortel STM16 fibre points ..
a pathetic 2.56gb/s each .. or 32 * ATM1 if you prefer ..  OK so it wasnt all
inter/intranet but it was still serious bandwidth ...:)



Reply via email to