ページで使用される配列に (json) オブジェクトを挿入する必要があります。私は jade で nodejs を使用していますが、以下のコードが私の目的に合っていると思いますが、うまくいきません。
//this code is in the template:
script.
otherPlayers = {};
each player in playerList
otherPlayers["#{player.playerId}"] = !{JSON.stringify(#{player})};
このページで期待される結果は次のとおりです。
<script>
otherPlayers = {};
otherPlayers[0] = {"playerId": 0, "playerName": "Leo" };
otherPlayers[1] = {"playerId": 1, "playerName": "Daniel" };
otherPlayers[2] = {"playerId": 2, "playerName": "Lucas" };
</script>
どんなヒントも受け入れられます。よろしくお願いします。