<!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. 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>
<span metal:define-macro="dateInput"<BR>
tal:define="name <metal:fill-slot="name">"<BR>
tal:define="idname string:${name}id"<BR>
tal:define="buttonname string:${name}button"<BR>
tal:define="initalValue <metal:fill-slot="value">"><BR>
<BR>
In here I would use name, idname, buttonname and initalvalue repeatedly, including inside some dynamically generated javascript. (I've pasted the complex stuff below.)<BR>
<BR>
</span><BR>
<BR>
Even though I would like to use macros for this sort of thing, I think it's too complex to ever work. I'm thinkning of doing it with a python script, then I would<BR>
<BR>
<span tal:replace="dateInput python:here.makeDateSelector('shipDate', shipment['date'])"></span><BR>
<BR>
but this doesn't seem right either. 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? <BR>
<BR>
<BR>
<BR>
The real body of my macro is something like:<BR>
<BR>
<span metal:define-macro="dateInput"<BR>
tal:define="name string:jim"><BR>
<BR>
<input type="text" name="receivedFromCustomer" id="recFromCust" value="8/27/2003" size="12" tal:attributes="value rma/receivedFromCustomer | nothing" onBlur="magicDate(this)"/><BR>
<button type="reset" id="recFromCustButton">...</button><BR>
<script type="text/javascript"><BR>
Calendar.setup({<BR>
inputField : "recFromCust", // id of the input field<BR>
ifFormat : "%m/%d/%Y", // format of the input field<BR>
showsTime : true, // will display a time selector<BR>
showsWeek : false, // made this up (jc)<BR>
button : "recFromCustButton", // trigger for the calendar (button ID)<BR>
singleClick : true, // double-click mode<BR>
step : 1 // show all years in drop-down boxes (instead of every other year as default)<BR>
});<BR>
</script><BR>
</span><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>