Refactor html into template