When calling displayBarNotification(stringIPass, 'success', 3500)
of nopmerce
originally defined in publicmon.js
seems the call fails when stringIPass
contains newlines
.
The error on the client-side was something like
Unexpected line break in a string literal
I tried replacing the C#
newline character in the ajax function to the js equivalent and it worked. However, I intend to keep the "newlines" for readability reasons. What approach would you suggest?
Pardon me for the lack of the exact error expr. but it's because I'm currently not at work. I will update tomorrow if necessary.
When calling displayBarNotification(stringIPass, 'success', 3500)
of nopmerce
originally defined in public.mon.js
seems the call fails when stringIPass
contains newlines
.
The error on the client-side was something like
Unexpected line break in a string literal
I tried replacing the C#
newline character in the ajax function to the js equivalent and it worked. However, I intend to keep the "newlines" for readability reasons. What approach would you suggest?
Pardon me for the lack of the exact error expr. but it's because I'm currently not at work. I will update tomorrow if necessary.
Share Improve this question edited Feb 12, 2020 at 18:09 Trevor 8,0046 gold badges33 silver badges52 bronze badges asked Feb 12, 2020 at 18:04 OnionOnion 311 silver badge7 bronze badges 2- developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – Teemu Commented Feb 12, 2020 at 18:06
- You can use the javascript scape function first – Hackerman Commented Feb 12, 2020 at 18:10
1 Answer
Reset to default 6Official documentation:
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.
Use back-ticks ( ` ) to introduce a template literal:
var example = `
this
is
a
test
`;
console.log(example);