[ZPT] tal replacements in javascript

Evan Simpson evan@digicool.com
Thu, 17 May 2001 15:09:30 -0400


From: "Thomas Olsen" <thomas@iconmedialab.dk>
> <script type="text/javascript" language="Javascript">
>     if(top.topFrame.document.images.status_light) {
>         top.topFrame.document.images.status_light.src = '<dummy
> tal:replace="here/image_status_subpath" /><dummy
> tal:replace="here/chatstatus" />.gif';
>     }
> </script>

TAL doesn't look inside of script tags.  You could do this:

<script type="text/javascript" language="Javascript"
  tal:content="string:var
src='${here/image_status_subpath}${here/chatstatus}.gif';>
var src='dummy.gif';
</script>
<script type="text/javascript" language="Javascript">
    if(top.topFrame.document.images.status_light) {
        top.topFrame.document.images.status_light.src = src;
    }
</script>

We're brainstorming ideas to make this better.

> BTW: is there no way of joining conditions as in <p
> tal:condition="(exists) /path/subpath; (exists) /path/othersubpath" /> ?

By 'join' do you mean boolean AND?  Only using a Python expression:

tal:define="c1 (exists) /path/subpath; c2 (exists) /path/othersubpath"
tal:condition="python:c1 and c2"

Cheers,

Evan @ digicool