[TurboGears] Re: KID got error while process javascript operator

2006-05-08 Thread Sven H.

Robin Haswell schrieb:
 In my limited experience some web pages I couldn't figure out any other 
 way then to generate javascript on the page. If this was a limitation of 
 javascript, my knowledge or my time, it didn't really matter.
 

 In my fairly large experience of JavaScript, you only *really* need to 
 generate JS when you need to 
 include page-specific data structures in your JS. I don't believe there are 
 any other cases where JS 
 needs to be generated. The long-term solution to this is fetching your 
 structures with XMLHTTP with 
 window.onload, but I think for now embedded JSON is fine.

 -Rob

 

   
If I have some content specific javascript data I usually abuse an event 
handler like this:

a class=transform href=/nonjslink onclick=return {foo: 1, bar: 
'xxx' };foo/a



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-07 Thread Robin Haswell


 Using comments to wrap something that you want to keep in the document 
 is a bad idea.  Sure, it might happen to work with Kid, but I still 
 wouldn't do it or recommend it.

That technique has been recommended for JS since day 1. It's the standard way 
of hiding JS from 
non-javascript-aware browser. You wrap it in a comment so if your user agent 
doesn't understand JS, 
it doesn't go printing it everywhere.

Not that you should be putting JS in your body/ though.

I'm fine with JS on-page when it only affects that page. Including it in a 
global JS file increases 
bandwidth. Including it in its own external file causes connection overhead (in 
HTTP/1.0)

 -bob

-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-07 Thread lateef jackson
Couple points that seem to be bubbling up:1) Kid is XML so '' needs to be escaped amp;2) In general practice it is good to keep all your _javascript_ in a .js static file if they it can reduce network usage becuase the static content can be reused. Take care not to keep specific functions that only apply to a single or a couple pages out of the global _javascript_ file.
3) If you have some page specific code that is easiest to put on the page use ![CDATA[]]. Page variables that are initialized, small simple functions or dynamic _javascript_.
4) As always the use of !-- -- is advised for older browser compatability (ofcourse if your site is like mine, browsers that don't _javascript_ won't be able to use the site so no loss)In my limited experience some web pages I couldn't figure out any other way then to generate _javascript_ on the page. If this was a limitation of _javascript_, my knowledge or my time, it didn't really matter. 
I vote that this question go into the FAQ.On 5/7/06, Robin Haswell [EMAIL PROTECTED]
 wrote: Using comments to wrap something that you want to keep in the document
 is a bad idea.Sure, it might happen to work with Kid, but I still wouldn't do it or recommend it.That technique has been recommended for JS since day 1. It's the standard way of hiding JS from
non-_javascript_-aware browser. You wrap it in a comment so if your user agent doesn't understand JS,it doesn't go printing it everywhere.Not that you should be putting JS in your body/ though.I'm fine with JS on-page when it only affects that page. Including it in a global JS file increases
bandwidth. Including it in its own external file causes connection overhead (in HTTP/1.0) -bob-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups TurboGears group.  To post to this group, send email to turbogears@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/turbogears  -~--~~~~--~~--~--~---


[TurboGears] Re: KID got error while process javascript operator

2006-05-07 Thread Robin Haswell

 In my limited experience some web pages I couldn't figure out any other 
 way then to generate javascript on the page. If this was a limitation of 
 javascript, my knowledge or my time, it didn't really matter.

In my fairly large experience of JavaScript, you only *really* need to generate 
JS when you need to 
include page-specific data structures in your JS. I don't believe there are any 
other cases where JS 
needs to be generated. The long-term solution to this is fetching your 
structures with XMLHTTP with 
window.onload, but I think for now embedded JSON is fine.

-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-07 Thread Bob Ippolito


On May 7, 2006, at 6:07 AM, Robin Haswell wrote:



 Using comments to wrap something that you want to keep in the  
 document
 is a bad idea.  Sure, it might happen to work with Kid, but I still
 wouldn't do it or recommend it.

 That technique has been recommended for JS since day 1. It's the  
 standard way of hiding JS from
 non-javascript-aware browser. You wrap it in a comment so if your  
 user agent doesn't understand JS,
 it doesn't go printing it everywhere.

It's not standard practice for XML.  Standard practice for XML is to  
use CDATA.  Comments in XML are comments and shouldn't carry anything  
meaningful and shouldn't really be expected to survive some kind of  
document transform.

Either way, I highly doubt any browsers (or other HTML parsing  
software) still exist that have a problem ignoring script tags --  
they've been with us for *over ten years*.  Day 1 was a hell of a  
long time ago.

-bob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-06 Thread Alberto Valverde


On 06/05/2006, at 3:19, Wenjie He wrote:

 Anybody have occur such situation?
 While using javascript operator  in KID template,
 KID can't parse template to html, and raise
 ExpatError: not well-formed (invalid token)

 How can I do a logic and operation in a kid template, instead?

Changing  to amp;amp should do the trick.

HTH,
Alberto

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-06 Thread Bob Ippolito


On May 6, 2006, at 2:41 AM, Alberto Valverde wrote:



 On 06/05/2006, at 3:19, Wenjie He wrote:

 Anybody have occur such situation?
 While using javascript operator  in KID template,
 KID can't parse template to html, and raise
 ExpatError: not well-formed (invalid token)

 How can I do a logic and operation in a kid template, instead?

 Changing  to amp;amp should do the trick.

Alternatively, keep your JavaScript out of the template. You really  
shouldn't put anything dynamic in there anyway.

-bob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-06 Thread Robin Haswell

Nah Javascript is fine in templates. All you need to do is place it in !-- -- 
comments for 
non-javascript-aware browsers. That includes Kid.

-Rob

Bob Ippolito wrote:
 
 On May 6, 2006, at 2:41 AM, Alberto Valverde wrote:
 

 On 06/05/2006, at 3:19, Wenjie He wrote:

 Anybody have occur such situation?
 While using javascript operator  in KID template,
 KID can't parse template to html, and raise
 ExpatError: not well-formed (invalid token)

 How can I do a logic and operation in a kid template, instead?
 Changing  to amp;amp should do the trick.
 
 Alternatively, keep your JavaScript out of the template. You really  
 shouldn't put anything dynamic in there anyway.
 
 -bob
 
 
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-06 Thread David Stanek
On 5/6/06, Robin Haswell [EMAIL PROTECTED] wrote:
Nah _javascript_ is fine in templates. All you need to do is place it in !-- -- comments fornon-_javascript_-aware browsers. That includes Kid.I usually use XML comments to hide my _javascript_. It seems like a more natural solution than ![CDATA ]]. On the other hand, I agree with Bob. Putting your _javascript_ into a .js file is a better solution for _javascript_ that is not dynamically created.
-- Davidhttp://www.traceback.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups TurboGears group.  To post to this group, send email to turbogears@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/turbogears  -~--~~~~--~~--~--~---


[TurboGears] Re: KID got error while process javascript operator

2006-05-06 Thread Bob Ippolito
On May 6, 2006, at 4:19 PM, David Stanek wrote:On 5/6/06, Robin Haswell [EMAIL PROTECTED] wrote: Nah _javascript_ is fine in templates. All you need to do is place it in !-- -- comments fornon-_javascript_-aware browsers. That includes Kid.I usually use XML comments to hide my _javascript_. It seems like a more natural solution than ![CDATA  ]]. On the other hand, I agree with Bob. Putting your _javascript_ into a .js file is a better solution for _javascript_ that is not dynamically created. Using comments to wrap something that you want to keep in the document is a bad idea.  Sure, it might happen to work with Kid, but I still wouldn't do it or recommend it.-bob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups TurboGears group.  To post to this group, send email to turbogears@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/turbogears  -~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-05 Thread lateef jackson
Try amp;amp; instead because kid is valid XML you need to use amp; to render _javascript_ correctly. You also could move it into a static _javascript_ file.Good luck,Lateef
On 5/5/06, Wenjie He [EMAIL PROTECTED] wrote:
Anybody have occur such situation?While using _javascript_ operator  in KID template,KID can't parse template to html, and raiseExpatError: not well-formed (invalid token)
How can I do a logic and operation in a kid template, instead?--I'm lazy, I'm coding.http://my.donews.com/henotii
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups TurboGears group.  To post to this group, send email to turbogears@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/turbogears  -~--~~~~--~~--~--~---


[TurboGears] Re: KID got error while process javascript operator

2006-05-05 Thread Matt Good

Or a CDATA block.

On Fri, 2006-05-05 at 21:41 -0400, lateef jackson wrote:
 Try amp;amp; instead because kid is valid XML you need to use amp;
 to render javascript correctly. You also could move it into a static
 javascript file.
 
 Good luck,
 Lateef
 
 On 5/5/06, Wenjie He [EMAIL PROTECTED] wrote:
 Anybody have occur such situation?
 While using javascript operator  in KID template,
 KID can't parse template to html, and raise
 ExpatError: not well-formed (invalid token)
 
 How can I do a logic and operation in a kid template,
 instead?
 
 --
 I'm lazy, I'm coding.
 http://my.donews.com/henotii
 
 
  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-05 Thread Kevin Dangoor

On 5/5/06, Matt Good [EMAIL PROTECTED] wrote:

 Or a CDATA block.

That's what I'd recommend. If you're not as familiar with writing XML:

script type=text/javascript![CDATA[

...your javascript here...

]]/script

Kevin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] Re: KID got error while process javascript operator

2006-05-05 Thread Wenjie He
thx for all of your advices.
I work better with KID now:)

On 5/6/06, Kevin Dangoor [EMAIL PROTECTED] wrote:

 On 5/5/06, Matt Good [EMAIL PROTECTED] wrote:
 
  Or a CDATA block.

 That's what I'd recommend. If you're not as familiar with writing XML:

 script type=text/javascript![CDATA[

 ...your javascript here...

 ]]/script

 Kevin

 



--
I'm lazy, I'm coding.
http://my.donews.com/henotii

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---