move code from template to view.coffee

Closes #9