conditional objects in templates

Thomas Bruederli roundcube at gmail.com
Sat Dec 2 18:48:13 CET 2006


Hi everybody

I guess I found a good way to handle conditions in a more flexible way.
With the changes in rev. 388 conditions in any PHP-styled form can be
added to dynamic template objects. The parser simply replaces some parts
of the expression and then eval it. This also enables complex conditions
with brackets and multiple ANDs and ORs.

For the preview pane implementation there's a simple conditions like
  <roundcube:if condition="config:preview_pane == true" />
in the mail.html template.


Currently there are three "arrays" which can be used for conditions:
  session	Access PHP session vars	
  config	Access any config parameter	
  request	Access any request parameter

The only thing that would cause some problems are greater-than signs in
such an expression (like "config:pagesize > 20"). This would be
considered as the end of the tag because quotes are not regarded in the
tag matching regexp.

I've already worked on a new template parsing functions which correctly
reads quoted attributes and which should also be capable for nested
if-else blocks. It's not ready yet but I guess for now, the current
solution will do the job.

Regards,
Thomas




More information about the Dev mailing list