[Templates] stonehenge.com cutting over to Template from Mason
hugh baker
hugh@tao.ca
06 Mar 2002 12:18:24 -0500
Harald Joerg <harald.joerg@fujitsu-siemens.com> writes:
> Perrin Harkins <perrin@elem.com> writes:
>
> > Randal L. Schwartz wrote:
> > > So how do I detect which URL maps to which link in this map, and
> > > then fire that bar and everything up the chain?
> >
> > You probably saw this coming (I am a broken record), but I think this
> > is an example of when you should use perl, not TT. It should be
> > pretty easy to make a nice data structure for this, look up your place
> > in it, and then hand the appropriate display data to TT.
>
> OTOH, one could rather easily set up the data structure in TT in a
> PREPROCESSed template. It is not as elegant as doing this in perl,
> but I found it very convenient to write a macro which enters a new
> document into the structure and then to call this macro for all the
> documents in the PREPROCESSed template. Every document can then
> access the data structure as if it had been created in perl.
i have found that TT is great for the heavy lifing of assembling
blocks of text and reducing repetition across a dataset, but no so
good for finer-grained operations like parsing a URI, grokking
parameters and the like. that said, i usually err on the side of
putting too much logic into templates.
hugh.