On 12-11-2008 at 10:41:35 romtek <[EMAIL PROTECTED]> wrote:

According to the manual, repeat/item/start should return *true* if item is the first one. However, it returns 1 instead of true and 0 otherwise.

In the code it's:
            case 'start':
                return $this->index === 0;

so it does return true. It may seem otherwise, because PHPTAL *prints* true as "1" and false as "0" in HTML. "true" and "false" *strings* are less likely to be useful representation of booleans in contexts other than inline Javascript.

However, if you output any values in Javascript, then HTML encoding is inappropriate there. You *have to* use json_encode() to reliably inserting values in Javascript:

        var b = ${php:true} // Wrong. Gives 1
        var b = ${structure php:json_encode(true)} // OK. Gives true

This is especially important for strings in Javascript, which can't be safely escaped with just htmlspecialchars() and addslashes().

regards, Kornel

PHPTAL mailing list

Reply via email to