> 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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment