2 Feb 2007 09:54
On templates
It's much fun to play around with ezc, but sooner or later you've to present
sth. to the user. Writing forms by hand sucks. A simple adressbuch which
takes nearly all possible content of a vCard takes at least six tables.
The main table subject already contains the columns:
'additional_names', 'birthday', 'family_name', 'fn', 'given_name', 'honorific_prefixes',
'honorific_suffixes', 'id', 'last_modified', 'note', 'organization', 'role', 'room', 'title'
So I need a possibility to create forms more easily then just plain HTML. An
answere could be to create some kind of custom block:
{field "family_name"}
The custom block now looks up the model definition, where it finds information
about the descriptive name of the field, the input type, maybe values for a
select-box or a REQUIRED/OPTIONAL flag. This approach could also allow the
creation of a view and an edit form from the same source.
Problem: custom blocks are not hardcoded in the compiled template, but
executed on runtime. But it's to expensive to lookup all these informations
on runtime.
So right now, I ask myself, which advantage I have by using templates instead
of writing good old PHP. You know the discussion, that PHP itself already is
a template language.
One general question: isn't it kind of insane, to write a compiler to output a
scripting language? Please don't take this doubt to serious...
Right now I think about writing a script, which analyzes my model and writes
templates for the list, view and edit templates. But isn't that even more
insane?
(Continue reading)



.
Well. I'm still not sure...
Thomas Koch
RSS Feed