[Zope] ZPT changing javascript (HOW?) - Easy with DTML

Christopher N. Deckard chris@globalfoo.net
Thu, 3 Oct 2002 12:20:14 -0500


Well, I tried the following, but it didn't work.  It parses just
fine.  Are "script" tags ignored when the PT is rendered?  I could
understand why.  

<SCRIPT type="text/javascript"
        tal:define="USER_NAME user/getUserName">
 function connect()
 {
  username = <span tal:replace="USER_NAME"/>;
  password = <span tal:replace="USER_NAME"/>;
  server = <span tal:replace="USER_NAME"/>;
  port = <span tal:replace="USER_NAME"/>;
  subRoomID = <span tal:replace="USER_NAME"/>;
  groupID = <span tal:replace="USER_NAME"/>;

  WBChat.Connect2(server,port,subRoomID,username,password,groupID);
 } 
</SCRIPT>

I'd think you could put the function in another PT
and do something like:

<script tal:content="structure container/javascriptThinger">
  Javascript
</script>

-Chris

On Wed, 2 Oct 2002 11:29:11 +0100, Pedro Beck Gomes da Costa spoke
forth:

> Hi!
> 
> I recently decided to change all my coding from dtml to page
> templates, but I now have a problem i cant solve. I need to change
> the javascript on html script blocks. A quick example in DTML of
> what i want to do and that works perfectly:
> 
> <HTML>
> <HEAD>
> <TITLE>Chat</TITLE>
> <SCRIPT type="text/javascript">
>  function connect()
>  {
>   username = <dtml-var "USER_NAME">;
>   password = <dtml-var "USER_NAME">;
>   server = <dtml-var "USER_NAME">;
>   port = <dtml-var "USER_NAME">;
>   subRoomID = <dtml-var "USER_NAME">;
>   groupID = <dtml-var "USER_NAME">;
> 
>    WBChat.Connect2(server,port,subRoomID,username,password,groupI
>    D);
>  } 
> </SCRIPT>
> 
> </HEAD>
> 
> <BODY>
> <!-- BODY HERE -->
> </BODY>
> </HTML>
> 
> Someone can help me on how to di this with ZPT??
> 
> Thanks in advance,
> 
> Pedro Costa
>