Line break inside string that is inside a template string

0

I know that to break lines within string, we use the \n operator. I also know that within template strings, we can do it using just the backslash in this way.

var string = 'Uma linha \
duas linhas \
três linhas'

So far, okay. But what if I have a string inside a string template, do I need to break the line inside it? Example:

var string2 = '$(this).text(var1 + "\n_________________\n")'

In case I need to pass this line of code inside a template string to another variable that will insert the code directly into the script tag of the page. Using \ n gives me a syntax error, and using the backshell style of template strings does not skip the line, it just creates a huge space instead of the backslash. How should I proceed?

    
asked by anonymous 23.11.2018 / 16:23

0 answers