Skip to content

Instantly share code, notes, and snippets.

@rapind
Created January 21, 2015 17:09
Show Gist options
  • Save rapind/1e6fe7a24a4513655847 to your computer and use it in GitHub Desktop.
Save rapind/1e6fe7a24a4513655847 to your computer and use it in GitHub Desktop.
Coffeescript version of the Mithril Tutorial's Todo View.
# See: http://lhorie.github.io/mithril/getting-started.html
todo.view = () ->
vm = todo.vm
m "html",
m "body",
m "input",
onchange: m.withAttr "value", vm.description
value: vm.description()
m "button",
onclick: vm.add.bind vm, vm.description
"Add"
m "table",
vm.list.map (task, idx) ->
m "tr",
m "td",
m "input[type=checkbox]",
onclick: m.withAttr "checked", task.done
checked: task.done()
m "td",
style: textDecoration: if task.done() then "line-through" else "none"
task.description()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment