3

I have a JavaScript function which returns a set of objects:

return Func("{{id}}", "{{name}}")

I have a problem with passing strings containing quotes, for instance "Dr.Seuss' "ABC""BOOk"" is invalid syntax.

I tried {{name|safe}} but to no avail. Any solution for this?

1 Answer 1

6

If I'm right in assuming that's a JavaScript function call you're trying to interpolate Django templating into, try the escapejs filter instead of safe.

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#escapejs

Sign up to request clarification or add additional context in comments.

1 Comment

I was looking for that for one hour... How happens that for me (like the OP), the escape tag didn't escape the quote/double quote like his example of : "Dr.Seuss' "ABC""BOOk"" ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.