Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@natew
Forked from ncammarata/gist:1831e3bcea38d45dc8ab
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natew/888b7e2e5bbbce0cd05e to your computer and use it in GitHub Desktop.
Save natew/888b7e2e5bbbce0cd05e to your computer and use it in GitHub Desktop.
store Tasks {
@tasks = []
@undone <- @tasks.filter(task => !task.done)
makeTask(task) { return { title: title, done: false } }
addTask() { @tasks.push(makeTask(task)) }
clear() { @tasks = @undone }
}
view Main {
@newText = ""
add() { Tasks.addTask(); @newText = "" }
<h1>Todo List</h1>
<div.task repeat={Tasks.tasks}>
<input type="checkbox" sync={.done} />
</div>
<div.toolbar>
<div.undone> {Tasks.undone.length} tasks left</div>
<button click={Tasks.clear()}>clear completed</button>
</div>
<input enter={add()} placeholder="New Task" />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment