I am running into a problem with escape/unescape with TG/genshi
template. I've put together a simple code below (very easy to
reproduce) to illustrate the problem.
Below is my test.html resides in the /templates directory. I expect
to see a border around the element "two", but looks like something is
not quite correct with the statement ("div > p") when using with
genshi template, I suspect it has something to do with escape/unescape
of ">", but not quite sure what must be done here. Any suggestion to
make this work is really appreciated. Thanks much in advance.
tpn
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"
py:replace="''"/>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div > p").css("border", "1px solid gray");
});
</script>
</head>
<body>
<p>one</p>
<div>
<p>two</p>
</div>
<p>three</p>
</body>
</html>
Write the "greater than" sign as ">" as it is appropriate in an XML
document?
Remember, Genshi templates must be valid XML.
Chris
> $(document).ready(function(){
> $("div > p").css("border", "1px solid gray");
>
> });
Either write the > as > or put a CDATA block around the $(document).ready
function.
Hi all,
I got it to work the way I wanted using CDATA method. Thanks to all
for your suggestions. If anyone is looking for the answer, below is
the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript"> /* <![CDATA[*/
$(document).ready(function(){
$("div > p").css("border", "1px solid gray");
});
/*]]>*/</script>
</head>
<body>
<p>one</p>
<div>
<p>two</p>
</div>
<p>three</p>
</body>
</html>
=========================
On Tue, Dec 29, 2009 at 12:15 PM, Thang Nguyen
<thang.p...@gmail.com> wrote:
> Thanks for all your suggestions, but let me clarify the situation a
> bit, maybe I was not clear at first.
>
> What I would like to see if there is a way to make the greater sign
> ">" remains as it is, not converted to ">". TG/Genshi seems to
> take ">" and convert it to ">" by default. Would CDATA method
> allow me to keep the greater sign as ">" when viewed under a browser ?
> I will give it a try and see if that works.
>
> tpn
On Tue, Dec 29, 2009 at 12:53 PM, Thang Nguyen
<thang.p...@gmail.com> wrote:
> Hi all,
>
> I got it to work the way I wanted using CDATA method. Thanks to all
> for your suggestions. If anyone is looking for the answer, below is
> the code:
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:py="http://genshi.edgewall.org/"
> xmlns:xi="http://www.w3.org/2001/XInclude">
>
> <head>
> <script src="http://code.jquery.com/jquery-latest.js"></script>
> <script type="text/javascript"> /* <![CDATA[*/
> $(document).ready(function(){
> $("div > p").css("border", "1px solid gray");
>
> });
> /*]]>*/</script>
> </head>
> <body>
> <p>one</p>
> <div>
> <p>two</p>
> </div>
> <p>three</p>
> </body>
> </html>
>
> =========================
>
>
>
> On Tue, Dec 29, 2009 at 12:15 PM, Thang Nguyen
> <thang.p...@gmail.com> wrote:
>> Thanks for all your suggestions, but let me clarify the situation a
>> bit, maybe I was not clear at first.
>>
>> What I would like to see if there is a way to make the greater sign
>> ">" remains as it is, not converted to ">". TG/Genshi seems to
>> take ">" and convert it to ">" by default. Would CDATA method
>> allow me to keep the greater sign as ">" when viewed under a browser ?
>> I will give it a try and see if that works.
>>
>> tpn
>>
>> On Tue, Dec 29, 2009 at 11:34 AM, Uwe Schroeder <u...@oss4u.com> wrote:
>>>