Hello: I have some troubles with nevow and the new lines. I'm taking datas from one form and after try to display them in a different page, like a simple text between simple "<td>" tags. Well, the problem is that the new lines are not display in the new page. Could anybody tell me how to fix this. Thank you very much. Here is the code form.html ----------------- < form method="post" name="formrecipients" nevow:render="formrecipients"> < nevow:attr name="action">< nevow:slot name="action"/></ nevow:attr> ... < td colspan="2"> < textarea name="description" rows="5" cols="50" class="formelements"></ textarea> </ td> ... </ from> file.html ---------------- < td colspan="3" class="wktdcontent" width="50px"> < div ID="demodiv" class="demo" style="display: none;"> < nevow:attr name="id">< nevow:slot name="id"/></ nevow:attr> < nevow:slot name="description">Description</ nevow:slot> </ div> </ td> file.py -------------- def render_messages(self, ctx, data): ctx.fillSlots("id", data.id) ctx.fillSlots("subject", data.subject) ctx.fillSlots("sender", data.sender) ctx.fillSlots("date", data.date) ctx.fillSlots("description", data.description) return ctx.tag
Alberto Trujillo wrote:
Hello: I have some troubles with nevow and the new lines. I'm taking datas from one form and after try to display them in a different page, like a simple text between simple "<td>" tags. Well, the problem is that the new lines are not display in the new page. Could anybody tell me how to fix this. Thank you very much.
if you want to display newlines with html you have to change them into <br> or <br /> (depending on which markup you are using). HTML/xHTML are substantially space and newline agnostic. -- Valentino Volonghi aka Dialtone Now Running MacOSX 10.4.1 Blog: http://vvolonghi.blogspot.com http://weever.berlios.de
Valentino Volonghi aka Dialtone wrote:
Alberto Trujillo wrote:
Hello: I have some troubles with nevow and the new lines. I'm taking datas from one form and after try to display them in a different page, like a simple text between simple "<td>" tags. Well, the problem is that the new lines are not display in the new page. Could anybody tell me how to fix this. Thank you very much.
if you want to display newlines with html you have to change them into <br> or <br /> (depending on which markup you are using). HTML/xHTML are substantially space and newline agnostic.
Do you know if there is any function in nevow that do this automatically. I don't mind to implement one, for the new line, but I'll allways have this problem with the specials characters.
Alberto Trujillo wrote:
Do you know if there is any function in nevow that do this automatically. I don't mind to implement one, for the new line, but I'll allways have this problem with the specials characters.
No there is none. You might want to use something like markdown (or napalm for the partial python implementation of Markdown in my sandbox) or ReST (you have to install docutils) or textile or one of the many others. If you just need to substitute the \n with <br /> just run a replace description.replace('\n', '<br />') before filling the slot so that you don't actually the original that the user inserted. -- Valentino Volonghi aka Dialtone Now Running MacOSX 10.4.1 Blog: http://vvolonghi.blogspot.com http://weever.berlios.de
Valentino Volonghi aka Dialtone wrote:
Alberto Trujillo wrote:
Do you know if there is any function in nevow that do this automatically. I don't mind to implement one, for the new line, but I'll allways have this problem with the specials characters.
No there is none. You might want to use something like markdown (or napalm for the partial python implementation of Markdown in my sandbox) or ReST (you have to install docutils) or textile or one of the many others.
If you just need to substitute the \n with <br /> just run a replace
description.replace('\n', '<br />') before filling the slot so that you don't actually the original that the user inserted.
Hi again Valentino. I've tried the method that you told me ... description = data.description.replace('\n', '<br />') ctx.fillSlots('description', description) but now what I see is the next result: line one<br />line 2 What's wrong?
On Wed, Aug 31, 2005, Alberto Trujillo wrote:
but now what I see is the next result:
line one<br /> line 2
If you have a look at the source of the page you're downloading, you'll probably see that what the web browser received was: line one<br />line 2 That is, Nevow has escaped the HTML tag <br /> for you. This is the default behaviour, to force it to not escape things, see this http://divmod.org/users/wiki.twistd/nevow/moin.cgi/FrequentlyAskedQuestions#... Since Nevow is designed to produce XML from Python objects, you may find that it's a better design to actually split up your string and use tags.br where you want line breaks, rather than starting to use Nevow to put tags in some places, but bypassing Nevow and inserting them directly in other places. -Mary
participants (3)
-
Alberto Trujillo
-
Mary Gardiner
-
Valentino Volonghi aka Dialtone