[ZPT] Content/Presentation Separation

Harry Wilkinson harryw@nipltd.com
Tue, 23 Apr 2002 17:11:45 +0100


On Tuesday 23 April 2002 6:44 pm, Grant Thibdeau wrote:
> This should be a zpt question because it ultimately ends up in the zpt. If
> it's not my apologies.  I have my page template, which calls a python
> script.  This python script gets some data and then formats it. Now, I can
> then put a big print statement in my script to output all that information
> like so:
>
> print "Quantity Special: Each box is only %s a box!" % (resRebatePrice)
>
> return printed
>
> Now, from what I can tell that is kind of wrong, because i'm not really
> separating my content from my presentation.  Or would this be acceptable
> separation?  I'm assuming I would want to access a formatted resRebatePrice
> inside of a ZPT, but how would I get a hold of it inside the zpt?  Define
> the script call then access it like
> tal:content="PythonScript/resRebatePrice" ?
>
> Thanks

Defining how you want it presented (like in your print statement there) is 
what ZPTs are for.  So, yes, use ZPTs for that.

Say you have a script that returns the value of resRebatePrice, called 
getResRebatePrice.... to present this information in a ZPT-ish way, you could 
write this in the ZPT:

<div tal:replace="string:Quantity Special: Each box is only 
${here/getResRebatePrice} a box!"> your formatted string will replace this 
text </div>

Or, you could do:

<p>Quantity Special: Each box is only <div 
tal:replace="here/getResRebatePrice">price goes here</div> a box!</p>



Harry