if (list)
return list.filter(e => e.active === true);
else
- return null;
+ return [];
});
njx.addFilter('idle', function(list) {
if (list)
return list.filter(e => e.active === false);
else
- return null;
+ return [];
+});
+
+njx.addFilter('map_prop', function(list, prop) {
+ if (list)
+ return list.map(e => e[prop]);
+ else
+ return [];
});
/* Load each of our game mini-apps.
<ul>
{% for game in games.active %}
<li>
- {{game.meta.name}}: {{ game.id }} {{ game.players.length }} players
- <ul>
- <li>
- Active players:
- {% for player in game.players|active %}
- {{ player.name }}
- {% endfor %}
- </li>
- <li>
- Idle players:
- {% for player in game.players|idle %}
- {{ player.name }}
- {% endfor %}
- </li>
- </ul>
+ {{game.meta.name}}: {{ game.id }} ({{ game.players|active|length }}/{{ game.players.length }})
+ <strong>
+ Active:
+ {{ game.players|active|map_prop("name")|join(", ") }}
+ </strong>
+ Idle:
+ {{ game.players|idle|map_prop("name")|join(", ") }}
</li>
{% endfor %}
</ul>
<ul>
{% for game in games.idle %}
<li>
- {{game.meta.name}}: {{ game.id }} {{ game.players.length }} players
- <ul>
- <li>
- {% for player in game.players %}
- {{ player.name }}
- {% endfor %}
- </li>
- </ul>
+ {{game.meta.name}}: {{ game.id }} ({{ game.players.length }}):
+ {{ game.players|map_prop("name")|join(", ") }}
</li>
{% endfor %}
</ul>