How to convert characters that have special meaning in HTML to HTML character entities
Hi All, I have a string that contains a <a href="http://www.mywebaddress.com">link</a> tag that I would like rendered as HTML when output but it only seems to render in the html page like this <a href="http://www.mywebaddress.com">link</a> To replace the characters, I tried this in my TAL: <tal:block tal:define="d_stand row/STANDFIRST | nothing; d_stand_replaced_chars python: (str(d_stand)).replace('>','>');"> <p tal:condition="d_stand_replaced_chars" tal:content="d_stand_replaced_chars" /> </tal:block> But it converted the '>' I replaced with a '>' back to a '>' upon rendering the string in a html page. Any ideas how I can achieve this? Jon
Jonathan Bowlas wrote:
Hi All,
I have a string that contains a <a href="http://www.mywebaddress.com">link</a> tag that I would like rendered as HTML when output but it only seems to render in the html page like this <a href="http://www.mywebaddress.com">link</a>
To replace the characters, I tried this in my TAL:
<tal:block tal:define="d_stand row/STANDFIRST | nothing; d_stand_replaced_chars python: (str(d_stand)).replace('>','>');">
<p tal:condition="d_stand_replaced_chars" tal:content="d_stand_replaced_chars" /> </tal:block>
But it converted the '>' I replaced with a '>' back to a '>' upon rendering the string in a html page.
Any ideas how I can achieve this?
tal:content="structure d_stand_replaced_chars" -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96
Whoa, speedy response! Thanks a lot, although I should've known this. <beats self around head> -----Original Message----- From: Max M [mailto:maxm@mxm.dk] Sent: 06 April 2006 13:24 To: public-me-NUjxgDMnZEaakBO8gow8eQ@ciao.gmane.org Subject: Re: How to convert characters that have special meaning in HTML to HTML character entities Jonathan Bowlas wrote:
Hi All,
I have a string that contains a <a href="http://www.mywebaddress.com">link</a> tag that I would like rendered as HTML when output but it only seems to render in the html page like this <a href="http://www.mywebaddress.com">link</a>
To replace the characters, I tried this in my TAL:
<tal:block tal:define="d_stand row/STANDFIRST | nothing; d_stand_replaced_chars python: (str(d_stand)).replace('>','>');">
<p tal:condition="d_stand_replaced_chars" tal:content="d_stand_replaced_chars" /> </tal:block>
But it converted the '>' I replaced with a '>' back to a '>' upon rendering the string in a html page.
Any ideas how I can achieve this?
tal:content="structure d_stand_replaced_chars" -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96
On 4/6/06, Jonathan Bowlas <jb012b8598@blueyonder.co.uk> wrote:
I have a string that contains a <a href="http://www.mywebaddress.com">link</a> tag that I would like rendered as HTML when output but it only seems to render in the html page like this <a href="http://www.mywebaddress.com">link</a>
To replace the characters, I tried this in my TAL:
<tal:block tal:define="d_stand row/STANDFIRST | nothing; d_stand_replaced_chars python: (str(d_stand)).replace('>','>');">
<p tal:condition="d_stand_replaced_chars" tal:content="d_stand_replaced_chars" /> </tal:block>
But it converted the '>' I replaced with a '>' back to a '>' upon rendering the string in a html page.
TAL escapes characters that have special meaning in HTML or XML by default, to avoid XSS attacks. You can force TAL to not do this with the 'structure' keyword, like so: <span tal:replace="structure string:<blink>Blinking</blink>">Not blinking</span> -- Martijn Pieters
participants (3)
-
Jonathan Bowlas -
Martijn Pieters -
Max M