[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqwebmail
Subject:    Re: [sqwebmail] Re: Proposal to make the SqWebMail highly user configurable and extensible
From:       Brian Candler <B.Candler () pobox ! com>
Date:       2003-10-28 16:00:12
[Download RAW message or body]

On Tue, Oct 28, 2003 at 07:40:38AM -0800, Sagara Wijetunga wrote:
> --- Brian Candler <B.Candler@pobox.com> wrote:
> > Designing a *good* templating engine is not
> > straightforward, and nor is rewriting sqwebmail to
> > use it.
> 
> It requires only 2 routines. One routine is to parse a
> Tag and the other routine to parse an entire template.

I said designing a *good* templating engine is not straightforward.

You need to be able to handle lists of items (i.e. instances of the same
HTML template inserted multiple times). I'm thinking of the folder index
(listing multiple messages) and the message display (listing multiple
headers). And in the case of a folder listing, you want different HTML
fragments for odd and even rows, so that they can be coloured differently.

In your style,

<html>
  <table>
    ${ListOfFolders}
  </table>
</html>

${ListOfFolders} would need to expand to *multiple* instances of two
different HTML fragments:

  <tr class="odd"><td>Sender1</td><td>Subject1</td></tr>
  <tr class="even"><td>Sender2</td><td>Subject2</td></tr>
  <tr class="odd"><td>Sender3</td><td>Subject3</td></tr>
  ... etc

So somewhere, the logic that ${ListOfFolders} is not a simple tag expansion
but is a series of alternating tags, needs to be encoded.

Then also, in your example, you said that the tags would be all be expanded
into the hashTable, and then the templates run. But what if one tag contains
another tag? You would need to expand the tags in the right order so that
all dependencies are met (i.e. if tag A makes use of tag B, then tag B must
be evaluated before tag A).

Then the next issue is, where are you going to store all these tag templates
(snippets of HTML)? If you store them all in separate files, then sqwebmail
may have to open and read 20 or 30 different files when expanding a single
template. That's very inefficient, as it has to be done for every CGI
invocation. So you'd probably need to store all the tags in a single file,
which can be read into RAM with delimiters to mark the start and end of each
tag, or indexed for quick random access (e.g. a db or cdb file), in which
case you need a tag compiler which takes those snippets and builds the
indexed representation.

Everything is possible. But I'm not volunteering for this one.

Brian.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic