首页 > 解决方案 > 在 Passage.render() 中使用 _.template(): SyntaxError: missing ) 在参数列表之后

问题描述

我在玩雪人(Twine 2),并试图让一些 if/else 语句根据一个人之前所做的事情来做某事(特别是根据一个人按下“等待”的时间长短)。我尝试的第一件事没有问题:

<%
if(s.wait == 3){
    print('"Well, it appears that we did it correctly after all." His voice sounds deep and gutteral, with a hint of annoyance. "For being some prophesied being, you sure like to keep people waiting. Even my patience has limits."');
    s.ichor = 4;
    } else if(s.wait < 3){
    print('"So this is the prophesied being?" His voice is deep and gutteral, practically beastial. "While I cannot say I had any expectations, you just seem... a little plain."');
    s.ichor = 5;
    }
%>

这里的段落运行没有问题,但是一旦到达下一个,它总是给出以下错误:

在 Passage.render() 中使用 _.template(): SyntaxError: missing ) 在参数列表之后

下一段:

<%
if(s.wait == 3) {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "I'll admit, I was worried for a moment there, though that we had messed it up, that it was all for naught? Glad it wasn't!"');
    s.sturm = 5;
    }
if(s.wait < 3 && s.wait > 0){
    print('"How exciting that it worked!" His voice is filled with excitment, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 6;
    } else {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 5;
    }
%>

我是java脚本的新手,所以我不知道问题是什么。任何帮助将不胜感激!

标签: javascriptsyntax-error

解决方案


改变这个

<%
if(s.wait == 3) {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "I'll admit, I was worried for a moment there, though that we had messed it up, that it was all for naught? Glad it wasn't!"');
    s.sturm = 5;
    }
if(s.wait < 3 && s.wait > 0){
    print('"How exciting that it worked!" His voice is filled with excitment, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 6;
    } else {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 5;
    }
%>

<%
if(s.wait == 3) {
    print("'How exciting that it worked!' His voice is filled with excitement, like a child looking a gift he just opened. 'I'll admit, I was worried for a moment there, though that we had messed it up, that it was all for naught? Glad it wasn't!'");
    s.sturm = 5;
    }
if(s.wait < 3 && s.wait > 0){
    print('"How exciting that it worked!" His voice is filled with excitment, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 6;
    } else {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 5;
    }
%>

您的引号导致语法错误,因为您在外面使用了单曲。

您也可以转义引用:

<%
if(s.wait == 3) {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "I\'ll admit, I was worried for a moment there, though that we had messed it up, that it was all for naught? Glad it wasn't!"');
    s.sturm = 5;
    }
if(s.wait < 3 && s.wait > 0){
    print('"How exciting that it worked!" His voice is filled with excitment, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 6;
    } else {
    print('"How exciting that it worked!" His voice is filled with excitement, like a child looking a gift he just opened. "So this is what you look like- I look forward to working with you!"');
    s.sturm = 5;
    }
%>

推荐阅读