Thanks a lot, Malcolm, You got me on the right track, I just needed to escape the string, like this:
var prices=[{% for price in prices %}[{{ price.0 }}, '{{ price.1| escape }}']{% if not forloop.last %},{% endif %}{% endfor %}]; I tried the `escapejs` filter. That didn't work. Then I tried the `escape` filter, that worked. Cheers, Sander. On 27 jan, 05:05, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Mon, 2009-01-26 at 14:40 -0800, SanPy wrote: > > For my website, I need to write this in one of my generated html's > > (dynamically, of course): > > > <script type="text/javascript"> > > var prices=[[0, '\u20ac 0'],[100, '\u20ac 100'],[150, '\u20ac 150'], > > [200, '\u20ac 200'],[250, '\u20ac 250'],[300, '\u20ac 300']]; > > </script> > > > BTW, \u20ac represents the € symbol. > > > Whatever I try, I can't write '\u20ac 0' dynamically. It shows up like > > u'\u20ac 0' or '\\u20ac 0', but never the required '\u20ac 0'. Can > > somebody please help me with this? > > How are you trying to do this? Do the values come from a string that > you're substituting into a template? > > If that's the case, have you looked at the "escapejs" filter ([1])? That > will allow you to use the € character in your raw data and the template > rendering will take care of suitably encoding it for Javascript > purposes. > > [1]http://docs.djangoproject.com/en/dev/ref/templates/builtins/#escapejs > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---