On Mon, Jun 21, 2010 at 2:17 PM, donato.gr <donato...@gmail.com> wrote:
> Hi,
> I had this code in a template file:
> alert('{% trans "a string" %}')
>
> It gave error when translated bacause the translated string had a '
> inside. So, I replaced " with ' in the template line and all worked
> fine.
>
> To avoid any problem with 'escape chars', is there a way to escape
> translated strings, like the 'escapejs' filter tag does?
> Something like "{% trans "a string" | escapejs %}"
>
> Thank you
>

Yes, instead of using {% trans "foo" %}, you can use this alternative
form, for use inside an output tag:

{{ _("foo")|escapejs }}

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to