[PHPTAL] right side expression evaluated using left side variable in tal:define

Ciprian Vieru devel.php at gmail.com
Thu Apr 16 08:07:10 CEST 2009


Hello,

It looks like
<tal:block tal:define="label preferences/label|label" tal:replace="structure
label"/>
result in a null value for variable label if preferences/label is not
defined, even if label is defined.

The problem comes from the generated code which looks like
...
if (($ctx->label = phptal_path($ctx->preferences, 'label', true)) !==
null):  ;
elseif (($ctx->label = $ctx->label) !== null):  ;
endif ;
...

This might not be a bug but the right side expression should be evaluated
first before assignment.
A quick workaround would be to do something like
<tal:block tal:define="xlabel preferences/label|label;label xlabel;"
tal:replace="structure label"/>
which works, but looks pretty ugly especially if you have lots of variables
to define in tal:define attribute.

Regards,
Ciprian Vieru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/phptal/attachments/20090416/f3d5398e/attachment.htm


More information about the PHPTAL mailing list