Hello :)

I'm not sure how much discussion there has been concerning the packaging of 
some basic generic Tales alongside PHPTal but certainly when putting together 
Ztal we decided it was only sensible to provide some facilities as standard to 
help people along.  Of course, all of them also work fine without having to use 
the rest of Ztal so feel free to take a look ;)

Looking at your suggestions in particular:


While a convenience it isn't really necessary to support 'else'. I do 
understand that your templates can get a little verbose in some cases but in 
most cases I've come across either the conditionals wrap a large block of code 
which can be macro'd or you need to set a single var to one of two values 
depending on a truth statement. For this latter case, Ztal has an 'isTrue' tale 
that takes 2 arguments (the value to test for truth and the value to return if 
the truth test passes) which works very well when combined with the chaining 
operator, for instance:

<tal:inline tal:define="myValue 
Ztal_Tales_Generic.isTrue:varToTest,valToReturnOnTrue | valToReturnOnFalse" />

Still, if it could be added without getting very syntactically messy (which I 
actually doubt) then I'd have no objection to a little convenience :)

> 2. Calling standard php functions

Obviously PHPTal already has support for calling php functions via the php: 
operator but I'd actually like to suggest that even this is really almost 
redundant. If you are writing modern php using classes, interfaces etc. and 
potentially using one of the many frameworks out there to provide standard 
objects pre-packaged for you then you should find that you can either get 
exactly what you want by calling a method on your var class instance (e.g. 
myClassInstance/myGetter) or you can write a very small number of generic Tales 
to do all you need. Again, looking at Ztal (which, obviously, is designed to 
work with Zend Framework), we have a simple Tale to support outputting of 
formatted dates from a Zend_Date object that we use extensively.

> 3. Combining attributes

Now here I would certainly agree with you - especially for chaining class names 
in the class attribute :) At the moment effectively having to define each 
possible class as a var and set it to either the value you want or to an empty 
string and then build a string full of ${} statements to chain them all 
together and then ending up with lots of possible whitespace is messy and I'd 
love to see a way to do this within the language. In the absence of language 
support, we are considering adding a concat tale to Ztal that will take a list 
of comma separated values and concatenate them in a kind of 'implode' style 
with a inter-value separator.

Robert Goldsmith
PHPTAL mailing list

Reply via email to