hi, I'm interesting to Markup. But I got some question about it. Think about I have a guestbook form which let people to fill but it may contain HTML tags, and even badly they are invalid XHTML. I originally use kid but now looking for a replacement because kid can't handle not well-formed XHTML. Cheetah and Django is on my list, but I like the kid style more than others. I found this
"""It is possible to include markup that is not well-formed in the output (which you may need to do in some cases). And if you need to include bad HTML markup but would like to still produce valid output, Markup provides a HTML-sanitizing stream filter."""
on markup's website, but I still totally have no idea how to use it, is it possible to be use in .html file simply and directly? and another questioin, is there a XML()-like function with Markup? thanks.
> hi, I'm interesting to Markup. But I got some question about it. Think > about I have a guestbook form which let people to fill but it may > contain HTML tags, and even badly they are invalid XHTML. I originally > use kid but now looking for a replacement because kid can't handle not > well-formed XHTML. Cheetah and Django is on my list, but I like the > kid > style more than others. I found this
> """It is possible to include markup that is not well-formed in the > output (which you may need to do in some cases). And if you need to > include bad HTML markup but would like to still produce valid output, > Markup provides a HTML-sanitizing stream filter."""
> on markup's website, but I still totally have no idea how to use > it, is > it possible to be use in .html file simply and directly? and another > questioin, is there a XML()-like function with Markup? thanks.
> BTW, is it possible to enhance the performance in future?
I'm constantly looking into ways to improve the performance. I'm not sure at this point whether it'll be possible to achieve a drastic improvement... if I had found a way, I would've done it already ;-)
Markup should already be faster than Kid in most (all?) cases, but I do think there's still room in a couple of places where performance could be improved.
Are you asking because templating performance has been an actual issue for you?
Hi, Chris. I got another problem with HTMLSanitizer, that is, the variable after filtering by HTMLSanitizer will can be use only once in .html file. for example:
# in the .py file content = 'This is a test.' content = HTML(content).filter(HTMLSanitizer()) greeting = "Hello World!"
# And in the .html file ${greeting} <span py:content="content">Content goes here</span> ${greeting} <span py:content="content">Content goes here</span>
# The actually output Hello World! This is a test. Hello World!
# However, it should be.. Hello World! This is a test. Hello World! This is a test.
> Hi, Chris. I got another problem with HTMLSanitizer, that is, the > variable after filtering by HTMLSanitizer will can be use only once in > .html file. for example:
> # in the .py file > content = 'This is a test.' > content = HTML(content).filter(HTMLSanitizer()) > greeting = "Hello World!"
> # And in the .html file > ${greeting} > <span py:content="content">Content goes here</span> > ${greeting} > <span py:content="content">Content goes here</span>
> # The actually output > Hello World! This is a test. Hello World!
> # However, it should be.. > Hello World! This is a test. Hello World! This is a test.
> I tested this with TurboGears. so is it normal?
I think this is because of the concept of event streams. 'HTML(content)' converts whatever is in 'content' into a stream of events which may then be rendered. But once rendered the stream is exhausted, and I don't think there is a way to reset it back to the beginning. This is why it is empty the second time around.
Moving the stream generation/filtering into the template should work, because then you can generate two independent streams:
.py: content = 'This is a test.' greeting = "Hello World!"
Oliver Cope wrote: > On 9/11/06, Olli <olliw...@gmail.com> wrote:
> > Hi, Chris. I got another problem with HTMLSanitizer, that is, the > > variable after filtering by HTMLSanitizer will can be use only once in > > .html file. for example:
> > # in the .py file > > content = 'This is a test.' > > content = HTML(content).filter(HTMLSanitizer()) > > greeting = "Hello World!"
> > # And in the .html file > > ${greeting} > > <span py:content="content">Content goes here</span> > > ${greeting} > > <span py:content="content">Content goes here</span>
> > # The actually output > > Hello World! This is a test. Hello World!
> > # However, it should be.. > > Hello World! This is a test. Hello World! This is a test.
> > I tested this with TurboGears. so is it normal?
> I think this is because of the concept of event streams. > 'HTML(content)' converts whatever is in 'content' into a stream of > events which may then be rendered. But once rendered the stream is > exhausted, and I don't think there is a way to reset it back to the > beginning. This is why it is empty the second time around.
> Moving the stream generation/filtering into the template should work, > because then you can generate two independent streams:
> .py: > content = 'This is a test.' > greeting = "Hello World!"