Parse errors for illegal expressions in templates

Closes #702. Previously, illegal JavaScript was tolerated by the parser, which gave rise to errors that were hard to debug. This fixes that