views:

43

answers:

2

I'm using Pylons/Genshi, and trying to show 'all recent comments' on my site with a Disqus javascript widget (Disqus is installed on the site, and I can post comments OK).

However, the code below produces a nasty 500 error:

TemplateSyntaxError: not well-formed (invalid token): line 25, column 121 (line 25 is the <script> line).

  <div py:def="content">
   <div id="recentcomments" class="dsq-widget">
    <h2 class="dsq-widget-title">Recent Comments</h2>
    <script type="text/javascript"
    src="http://disqus.com/forums/wdmmg/recent_comments_widget.js 
    num_items=5&hide_avatars=0&avatar_size=32&excerpt_length=200"></script>
   </div>
  </div>

Weirdly, I think it might be something to do with the & symbols in the GET request, because using

    <script type="text/javascript"
    src="http://disqus.com/forums/wdmmg/recent_comments_widget.js
    ?num_items=5"></script> 

in the same line works fine. Does Genshi dislike & symbols, or is something else going on?

A: 

In the first snippet you don't have ? before num_items and in the second you do. Try adding it to the first one and check, if it works.

gruszczy
Well spotted - but that wasn't the problem, I checked again...
AP257
+1  A: 

In XML, you should encode your ampersands, since they have special meaning.

Correct way to use them in urls is recent_comments_widget.js?num_items=5&amp;hide_avatars=0&amp;avatar_size=32&amp;excerpt_length=200

Daniel Kluev
That seems to solve the problem - thanks.
AP257