<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.6944.0">
<TITLE>complex macro usage</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=2>Hi, I'd like to do something that is probably too complex for a metal:define-macro.&nbsp; I've got a complex set of javascript and html for a javascript date selector, and it would be great to get the complexity out of my page templates.<BR>
<BR>
I'd like to do something like the (invalid) following code:<BR>
<BR>
&lt;span&nbsp; metal:define-macro=&quot;dateInput&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tal:define=&quot;name &lt;metal:fill-slot=&quot;name&quot;&gt;&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tal:define=&quot;idname string:${name}id&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tal:define=&quot;buttonname string:${name}button&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tal:define=&quot;initalValue &lt;metal:fill-slot=&quot;value&quot;&gt;&quot;&gt;<BR>
<BR>
In here I would use name, idname, buttonname and initalvalue repeatedly, including inside some dynamically generated javascript.&nbsp; (I've pasted the complex stuff below.)<BR>
<BR>
&lt;/span&gt;<BR>
<BR>
Even though I would like to use macros for this sort of thing, I think it's too complex to ever work.&nbsp; I'm thinkning of doing it with a python script, then I would<BR>
<BR>
&lt;span tal:replace=&quot;dateInput python:here.makeDateSelector('shipDate', shipment['date'])&quot;&gt;&lt;/span&gt;<BR>
<BR>
but this doesn't seem right either.&nbsp; I'm coming from a background of some complex JavaWebComponents in the Tapestry framework.<BR>
<BR>
What's the best way to do this sort of thing?&nbsp;<BR>
<BR>
<BR>
<BR>
The real body of my macro is something like:<BR>
<BR>
&lt;span&nbsp; metal:define-macro=&quot;dateInput&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tal:define=&quot;name string:jim&quot;&gt;<BR>
<BR>
&lt;input type=&quot;text&quot; name=&quot;receivedFromCustomer&quot; id=&quot;recFromCust&quot; value=&quot;8/27/2003&quot; size=&quot;12&quot; tal:attributes=&quot;value rma/receivedFromCustomer | nothing&quot; onBlur=&quot;magicDate(this)&quot;/&gt;<BR>
&lt;button type=&quot;reset&quot; id=&quot;recFromCustButton&quot;&gt;...&lt;/button&gt;<BR>
&lt;script type=&quot;text/javascript&quot;&gt;<BR>
&nbsp;&nbsp;&nbsp; Calendar.setup({<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inputField&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; &quot;recFromCust&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // id of the input field<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ifFormat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; &quot;%m/%d/%Y&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // format of the input field<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; showsTime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; true,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // will display a time selector<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; showsWeek&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; false,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // made this up (jc)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; button&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; &quot;recFromCustButton&quot;,&nbsp;&nbsp; // trigger for the calendar (button ID)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; singleClick&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; true,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // double-click mode<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; step&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // show all years in drop-down boxes (instead of every other year as default)<BR>
&nbsp;&nbsp;&nbsp; });<BR>
&lt;/script&gt;<BR>
&lt;/span&gt;<BR>
<BR>
So you see I have a lot of javascript where I probably can't use metal:fill-slot.<BR>
<BR>
Thanks in advance!<BR>
-Jim<BR>
</FONT>
</P>

</BODY>
</HTML>