09/04/02 20:08:57, [EMAIL PROTECTED] (Randal L. Schwartz) wrote: >I'd say a source-to-source translator would be worth investing in, >then, as long as there are no semantics in your templating system that >don't map well into a TT construct. In fact, you could even >do it inline: > >[% FILTER YourSystemToTT | tteval %] >... your template here ... >[% END %] > >The tricky part is writing "YourSystemToTT". :)
Hmm... part of the problem here is doing it in a way which doesn't compromise the efficiency gains of using TT. I'd like to make sure our template code is only parsed once under a persistent environment if possible. After some preliminary work, it looks like TAGS <! > INTERPOLATE ON ... provides a first approximation to the look and feel of our templates. Then any automagic HTML rewriting can be done via a filter, although this isn't the absolutely most efficient way imaginable. For instance, I guess I'll need a filter to implement our sticky HTML forms: - Form inputs are 'tied' to particular template variables (e.g. '<input type="hidden" name="author" tied="&user:name">'), and when the template is processed, the input's value is intelligently set to the value of the template variable. This works for all flavours of HTML form input. Our current system breaks out the form input in the template parse tree, and returns the correct HTML at output time. Under TT I gather I would need a filter instead, which would have to find & replace through the whole of the filtered HTML - or run our engine's parser on it. I suppose if we write a filter which parses the template code, then caches the parse tree and returns results based on that, it could work OK, but that seems a bit like the whole reinventing the wheel thing again. Have I missed something, or is this the way to do it? We really like HTML rewriting, because it makes our templates very WYSIWYG. One of our recent extensions allowed our template builders to drop a textarea on a form, change <textarea name="blah"></textarea> to <textarea name="blah" dhtml></textarea> and voila, IE5 users get to edit the text in the textarea using the (dubiously secure) DHTML editor ActiveX component while everyone else uses the regular textarea. How do other people do automagic HTML rewriting under TT? Is it filters all the way? Many thanks for everyone's responses. Simon McGregor
