Open baszoetekouw opened 3 weeks ago
This is a bit of a challenge since Manage is obviously not PHP.
One, slightly crude approach could be that EB syntax checks any incoming manipulation on PUSH, and refuses to update when this has a syntax error
There is no native PHP way to syntax check an AM AFIK. You either eval / include the php code or you invoke the php binary with the -l option. A client side syntax hi-lighting exists (e.g. highlight.js). I think a syntax hi-light might already help a lot with catching syntax errors. In the end the idea is minimalise th use attribute manipulations.
There are ways to do something with the result of highlight.js: https://highlightjs.readthedocs.io/en/latest/plugin-recipes.html
Could make the save-button greyed-out if the result indicates a syntax error?
I've tested it and this works to test any AM code for parse errors:
try {
@eval($am);
} catch (ParseError $e) {
echo "Dat ging dus mis. Want: " . $e->getMessage();
exit(1);
}
The monkey tail is there to avoid notices and warnings because the needed variables for an AM to function are not set.
To catch obvious mistakes, it would be nice if we could syntax-check the AM PHP code before it can be submitted. Also adding syntax-coloring would help to catch problems.