coffeescript多行string编译成多行string

怎么这个string

"answer to life the universe and everything is #{40+2} " 

编译成

 " answer to life the universe and everything is " + (40 + 2) + ""; 

我如何强制coffescript保持多行(保持string插值不变):

  "answer \ to life \ the universe \ and everything \ is \ "+(40+2) 

尝试使用heredoc语法:

 myString = """ answer to life the universe and everything is #{40+2} """ 

这转换为这个javascript:

 var myString; myString = "answer\nto life\nthe universe\nand everything\nis\n" + (40 + 2); 

真的没有任何意义,使它实际上在编译的JavaScript视觉上的新行,在那里?

我同意在定义长string时能够保留缩进是很好的。 你可以在javascript中使用string添加这个效果在coffeescript中,就像你可以在javascript中一样:

 myVeryLongString = 'I can only fit fifty-nine characters into this string ' + 'without exceeding eighty characters on the line, so I use ' + 'string addition to make it a little nicer looking.' 

评估

 'I can only fit fifty-nine characters into this string without exceeding eighty characters, so I use string addition to make it a little nicer looking.'