Meteor Spacebars - 预期的标识符,数字,字符串,布尔值或null

时间:2014-07-31 13:40:13

标签: javascript meteor

我有一个功能,如果游戏中有一个玩家,则返回true

   Template.gamePage.searching = function() {
        var game = GameCollection.findOne({current: true});
        if(game.players.length === 1) {
            return true
        }
    };

如果此搜索功能返回true,我想通过空格键显示以下文本:

        {{#if {{searching}}}}
            <h1>Searching for an opponent</h1>
            <div>
            {{> spinner}}
            </div>
        {{/if}}

我收到以下错误:

client/views/games/game_page.html:35: Expected identifier, number, string, boolean, or null
...>.             {{#if {{searching}}}}     ...

2 个答案:

答案 0 :(得分:1)

尝试:

{{#if searching}}
      <h1>Searching for an opponent</h1>
      <div>
         {{> spinner}}
      </div>
{{/if}}

答案 1 :(得分:0)

此:

 {{#if searching}}
            <h1>Searching for an opponent</h1>
            <div>
              {{> spinner}}
            </div>
 {{/if}}