On Mon, 21 Jan 2008 10:43:21 -0000, Anton Andrievskij <[EMAIL PROTECTED]> wrote:

I have to fill JavaScript array using PHPTAL attributes.

Whether I can use some <span ...tal-attributes here..></span> inside
<script></script> construction?

I'm afraid that might be difficult with pure PHPTAL. To avoid compatibility problems with non-XHTML browsers (like Internet Explorer), you should use <![CDATA[ section in scripts, but by definition that also stops PHPTAL tags from being executed.

You may need to use plain PHP there. $ctx object allows you to access PHPTAL's variables:

<script type="text/javascript">/*<![CDATA[*/
  var items = <?php echo json_encode($ctx->items); ?>;

This will create JavaScript variable items from PHPTAL's variable items (json_encode() automatically handles arrays, objects, etc.)

regards, Kornel

PHPTAL mailing list

Reply via email to