I have this valid CoffeeScript and wish to convert it to LiveScript. Can someone explain why it fails to convert? Also to give a converted one?
TodoCtrl = (scope) ->
scope.addTodo = ->
scope.todos.push
text: scope.todoText
done: false
scope.todoText = ''
You can use this to compile CoffeeScript.
You can use this to compile LiveScript.
You are calling the function
scope.todos.pushagainst an implicit block starting with an implicit object. You must usedoin LiveScript, as it does’t do this special case (just think ofdoas parentheses around the block). See https://github.com/gkz/LiveScript/issues/50 for reasons.The code you want:
which is equivalent to (ie
dois just parentheses)Glad to see you using LiveScript!