Open bkerin opened 2 years ago
Interesting error. BTW might want to use % }
at the end in the example as that is also an error, but not the interesting one here.
All the examples use % } else {
so might never been tested, or might not he recommended syntax.
@bkerin. Your example has a blank line between % }
and else {
and that blank line turns into an output "a new line" in the transpiled(?) template.
If you stick a %
at the front of that blank line, or omit it it'll work fine:
% if (...) {
yes.
% }
% else {
nope.
% }
~~
A non-cuddled-else-enjoyer
Indeed, a blank line in between code lines won't work. This is expected behaviour.
Steps to reproduce the behavior
It's probably known and unavoidable but this syntax in a template:
Causes a syntax error:
syntax error at template sign_in.html.ep line 27, near "; else" syntax error at template sign_in.html.ep line 82, near "} $_O " Global symbol "$_O" requires explicit package name (did you forget to declare "my $_O"?) at template sign_in.html.ep line 82. 22
23
<%= $error %> 24
25
% } 26
27
% else { 28
Just removing the blank line between % } and % else { fixes it:
Some note about this behavior in https://docs.mojolicious.org/Mojolicious/Guides/Rendering or something might be good
Expected behavior
works like perl
Actual behavior
EXPLAIN WHAT HAPPENED INSTEAD HERE