I render some data with Twig
and do somethink like this:
var products = {
{% for item in items %}
{{ item.id }} : {
'title': '{{ item.title }}',
'info': '{{ item.info }}',
}
}
There is an error, caused by line breaks in item.info
variable.
I tried some tricks: replace \\n\\r
to <br />
etc.
What should I do?
UPD #1
Error message: Uncaught SyntaxError: Unexpected token ILLEGAL
UPD #2
The replacement of \\n
and \\r
does without problems. The problem is that I need variable to be with line-breaks , not in one line.
Try end each line with a backslash ie \\ For example
console.log("Line\
New")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.