On Fri, 30 May 2008 11:12:04 +0100, Christian Welzel <[EMAIL PROTECTED]> wrote:

Is your JavaScript is between a CDATA block ?


This does not work, because we want to use some phptal stuff in the
js code section to generate parts of the code.
As soon as i add CDATA, i get errors like this one: "Unable to find path plane"

An example of our js code section:

<span tal:omit-tag="" tal:repeat="plane plane_values">
p_speed[${repeat/plane/index}] = ${plane/speed};
p_capacity[${repeat/plane/index}] = ${plane/capacity};
</span>

You could reorganize data a bit and simplify generation of the array:

p_speed = ${php:json_encode(plane_speeds)}
p_capacity = ${php:json_encode(plane_capacities)}

(despite what the name suggests, json_encode isn't limited to JS objects and handles generation of whole arrays, strings and ints very well).

If you need HTML-compatible JS block with loop in it, you'll have to use multiple CDATA blocks this way:

<tal:block tal:repeat="plane plane_values">
/*<![CDATA[*/ code /*]]>*/
</tal:block>

--
regards, Kornel

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

Reply via email to