Beno]
I have the following Python Script (*not* External Script):
import string
size = string.atoi(size)/1280 css = "<style type='text/css'>" css += ".headline { position: absolute; top: " + str(100*size) + "; left: " + str(150*size) + "; font-style: 800 " + str(40*size) + "px futura }" css += ".belowHeadline { position: absolute; top: " + str(150*size) + "; left: " + str(250*size) + "; font-style: italic " + str(25*size) + "px verdana }" css += "</style>" return css
It isn't rendering properly because the brackets are being translated into ASCII. How do I prevent this?
Do not use Python to write markup. Return a data structure to dtml and use dtml to create the markup (or use zpt). For example - In script scaleSizes(size) : real_size=string.atoi(size)/1280 values={'top':str(100*real_size), 'left':str(150*real_size)} return values In a dtml page or method: <dtml-let sizes="scaleSizes(size)"> <style type='text/css'> .headline { position: absolute; top:<dtml-var "sizes['top']">; left:<dtml-var "sizes['left']">} </style> </dtml-let> In other words, let Python do what it is good at and let dtml or zpt do what it is good at - which is rendering markup. The result is a lot more readable and maintainable. Cheers, Tom P
participants (1)
-
Passin, Tom