I wanted to preserve newlines in the generated webpage. I had a
solution with split in my template. Something like:
#####
<element py:strip="" py:for="line in blogEntry.entryText.split('\n')">
    ${line}<br/>
</element>
#####

I made the following function:
#####
def splitLines(thisText):
    if thisText == None:
        return []
    thisText = thisText.replace('&', '&amp;')
    thisText = thisText.replace('<', '&lt;')
    thisText = thisText.replace('>', '&gt;')
    return '<br/>'.join(thisText.split('\n'))
#####

and now I can put the following in my template:
#####
${XML(tg.splitLines(blogEntry.entryText))}
#####

This is more clear and I am rid of the <br/> at the end.

-- 
Cecil Westerhof

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to