_hyperscript
_hyperscript copied to clipboard
If/else chaining requires multiple "end" keywords
The documentation says "You can chain if/else commands together in the usual manner." I understand "the usual manner" is to either allow "if ... else if ... else if ... else ... end" or to have a separate "elif", "elsif", "elseif" or similar keyword for chaining. Instead of chaining, the Hyperscript implementation seems to require nesting. Because "end" can sometimes but not always be elided, this is not always clear but can result in parse errors in following code.
Example: https://jsfiddle.net/_jks/hsqtw243/
This outputs an error message in the console that includes "Expected 'end' but found 'catch'".
Fixed example: https://jsfiddle.net/_jks/hsqtw243/3/
Note how the "end end" allows parsing to continue as a clue that the statements are nested instead of chained.