Good to know the problem is solved.
Yes, those syntax errors are confusing, I admit. They are generated by the Ace code editor which is managing the template - the embedded Twig code isn't valid PHP. You can turn off Ace if you wish by customising the question or its prototype. There's a checkbox "Template uses Ace" at the bottom of the Customisation panel.
I prefer to have it on by default, myself, because syntax colouring makes it much easier to edit large templates. Also, nearly all my templates are in Python nowadays, regardless of what language the question is asking for, and the double braces are generally valid Python.
For small PHP templates, though, the Ace editor might be more of a hindrance than a help.