> On Oct 26, 11:57 am, "Cooke, Mark" <[email protected]> wrote: > > Folks, > > > > I am trying to put some javascript into my genshi template > > (for a plugin) but it is rejected as follows: > > > > TemplateSyntaxError: not well-formed (invalid token): line > > 32, column 18 > > > > ...which turns out to be the first '<' character in the line: > > > > if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) > > > > So I have been searching to find out how to include > > javascript in genshi templates and can only find questions > > but no documentation or answers I understand. > > > > I am using `<xi:include href="layout.html" />` and trying > > to include the <script>...</script> in the <head>...</head> > > block. What am I doing wrong? > > > > Many thanks for any help, > > > > ~ mark c
> -----Original Message----- > From: [email protected] On Behalf Of osimons > Sent: 26 October 2011 15:41 > To: Trac Users > Subject: [Trac] Re: How do I include javascript in trac > genshi template? > > Templates are XHTML and need to be parsed correctly. < is a token > reserved for XML tags/elements, so you need to escape it (as <) > or wrap the code in a CDATA section. This is a general web > XML/XHTML/HTML/JavaScript issue, and lots of information > available on the web: > > http://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-within-a-script-tag > > > :::simon Thanks very much simon, that is a great post to reference. For the list, I fixed my issue by moving the offending code into an external file (when I eventually worked out how the INavigationContributor get_navigation_items function should work), however the post referenced seems to recommend the following construct:- <script> //<![CDATA[ ...code... //]]> </script> Thanks again, ~ mark c -- You received this message because you are subscribed to the Google Groups "Trac Users" 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/trac-users?hl=en.
