Can you imagine how much of a pain that's going to be for my search
snippets! A single regex is going to turn in to lines of loop code!
Surely there must be an easier way?
Is it possible to sanitise my string before it is sent to the template?
Then I could run the regex on the sanitised version and dump that in to
XML()
Cheers
-Rob
Kevin Dangoor wrote:
> 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 & 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
-~----------~----~----~----~------~----~------~--~---