Hi,

Yes, "paths" can resolve to method calls, in fact methods take precedence over properties. The logic can be seen in PHPTAL_Context::path().


However it's not allowed to use arguments in path expressions. The php modifier is needed in those cases. ie:

<td tal:define="username php:object.GetVar('username')" tal:content="username">Username</td>

regards,
/imv

On 12/17/09 4:44 AM, Scott Trevithick wrote:
Hello all,
Please forgive a newbie question.

In the book _PHP In Action_ by Reiersol, the author demonstrates method calls in PHPTal as a means of accessing variables. For ex.,

<td tal:content="user/getUsername">Username</td>

However, I have only ever seen examples of PHPTal accessing public member variables or elements within associative arrays. Is the above example valid?

Without having to use PHP syntax, can PHPTal access variables by using getter methods like this?

Would it be possible to go step further, without going to PHP and say

<td tal:content="object/GetVar('username')>Username</td>

I know I'm pushing the limits of template logic, but it's good to know what is supported.

thanks,
Scott


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to