Re: preventing escaping of less-than and greater-thans in tal:replace
Charlie Clark <[email protected]> Mon, 14 Aug 2006 19:45:35 +0200
| Newsgroups | gmane.comp.web.zope.page-templates |
|---|---|
| Message-ID | <[email protected]> |
Am 14.08.2006 um 19:27 schrieb Don Morrison:
>> Eek string replacements are so much uglier than Python string format!
>> Is it just me who thinks what you're doing is wrong.
>
> Charlie, I just said myself it was wrong and I'm asking for help
> because even if it did work it would be ugly and inelegant. I left it
> wrong to show you I'm trying to prevent escaping. Don't pretend to not
> understand this just to make fun of me. :)
I wasn't making fun of you.
>> Anyway I think what you're after is tal:source which is very much in
>> the Zope Book in the chapters on PageTemplates.
>
>
> I don't see it in 2.6 or here in 2.7:
Sorry, it's "structure" you want to use.
<tal:replace=3D"structure <some tag or other>">
Now, if you are going to generate some complex tag then you are best =20
of doing this in a PythonScript and returning the string to the =20
template. However, I do not think that is the way to want you want as =20=
I this only makes sense for extremely dynamic content. In my view =20
it's better to use standard tags.
Your source is virtually impenetrable to me which I think is a guide =20
to it being wrong.
<span tal:define=3D"r record/name; id record/task_id; mylt
string:'<'; mygt string:'>';"
tal:replace=3D"string:${mylt}option label=3D'${r}'
value=3D'${id}'${mygt}${r}${mylt}/option${mygt}"></span>
<option tal:attributes=3D"label record/name; value record/task" =20
content=3D"record/value"></option>
No formatting required at all. At least I think that's what you want!
Charlie
Charlie Clark
Helmholtzstr. 20
D=FCsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226