On 5/9/06, Robin Haswell <[EMAIL PROTECTED]> wrote:
> 1. When I want to put <strong>..</strong> around keyword terms in search
> result snippets
>
> 2. In one of my apps, printing one of my models returns a string with a
> <span> around it. I'd like to span to be left alone but the contents of
> the span to be sanitised.
>
> I was wondering if anyone could point me on how to do this? Ideally I
> think you should be able to do ' "my string" + XML("<tag>") +
> "something" + XML("</tag>") + "some more cruft" ', and return a
> generator, but at the moment I just get a TypeError :'(

I'd recommend creating cElementTree Elements.

In [1]:from cElementTree import Element

In [2]:e = Element("span")

In [3]:e.text = "This text is yours & mine."

In [8]:import cElementTree as ET

In [9]:ET.dump(e)
<span>This text is yours &amp; mine.</span>

You should be able to drop the element object straight into your template.

Kevin

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to