Mithril Tests

by ramnathv

CoffeeScript

binds = (prop) ->
  oninput: m.withAttr('value', prop)
  value: prop()
App =
  controller: ->
    firstName: m.prop("")
    lastName: m.prop("")
    fullName: -> @firstName() + " " + @lastName()
  view: (ctrl) ->
    m "#person", [
      "First Name: ", m("input#firstName", binds(ctrl.firstName)), m('br'),
      "Last Name: ", m("input#lastName", binds(ctrl.lastName)), m("br"),
      "Full Name: ", m("span", ctrl.fullName())
    ]
    
m.mount(document.body, App)