Skip to content

Instantly share code, notes, and snippets.

@mplatts
Created November 26, 2014 02:05
Show Gist options
  • Save mplatts/261449f1663b2bbb9790 to your computer and use it in GitHub Desktop.
Save mplatts/261449f1663b2bbb9790 to your computer and use it in GitHub Desktop.
templates2 - 2
# server/fixtures.coffee
if Teams.find().count() == 0
_([
{name: 'Barcelona'}
{name: 'Manchester City'}
]).each (data) -> Teams.insert(data)
if Games.find().count() == 0
game = {
completed: false
created_at: new Date
teams: [
{name: 'Barcelona', id: "1", score: 0}
{name: 'Manchester City', id: "2", score: 0}
]
}
Games.insert(game)
<!-- client/views/game.html -->
<template name="game">
<li>
{{teams.[0].name}}
vs
{{teams.[1].name}}
</li>
</template>
<!-- client/views/games.html -->
<template name="games">
<h3>Games</h3>
<ul>
{{#each games}}
{{> game}}
{{/each}}
</ul>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment