templates: fix code generation for expressions for observe() callback.
fixes #258