Can I use a Coffeescript switch
block in the eco templating engine? I tried a couple of variations, but I keep getting unexpected dedent
errors.
Update: To appease the downvoters, here is what I expected to work
<% switch x : %>
<% when 1 : %>
one
<% end %>
<% when 2 : %>
two
<% end %>
<% end %>
But I get "Parse error on line 5: unexpected dedent"
ECO templates don't appear to support the switch
statement.
The generated CoffeeScript code for your code is:
switch x
__out.push '\n'
when 1
__out.push '\n one\n'
__out.push '\n'
when 2
__out.push '\n two\n'
__out.push '\n'
The two __out.push '\n'
lines after switch x
and the end of the second when
statement don't seem to allow this CoffeeScript snippet to compile into JavaScript.
Looking through the code, I couldn't figure out how to prevent those lines from being printed. This might be a good bug to report to the guys that make eco.