From: Farrel Lifson Date: 2005-05-10T17:17:01+09:00 Subject: Case statements and ERB Hi Rubyists, While writing a template with ERB I found that case statements do not seem to work: irb(main):001:0> template =< irb(main):003:0" <% when 1 %> irb(main):004:0" <%= "one" %> irb(main):005:0" <% when 2 %> irb(main):006:0" <%= "two" %> irb(main):007:0" <% else %> irb(main):008:0" <% "more than two" %> irb(main):009:0" <% end %> irb(main):010:0" EOS => "<% case number %>\n<% when 1 %>\n<%= \"one\" %>\n<% when 2 %>\n<%= \"two\" % >\n<% else %>\n<% \"more than two\" %>\n<% end %>\n" irb(main):011:0> require 'erb' => true irb(main):012:0> erbRunner = ERB.new(template) => # irb(main):013:0> erbRunner.run(binding) SyntaxError: compile error (erb):1: syntax error _erbout = ''; case number ; _erbout.concat "\n" ^ (erb):2: syntax error when 1 ; _erbout.concat "\n" ^ from (erb):2 from (irb):13 (in this example no object number is defined but "more than two" should be printed out) Are case statements not allowed in ERB or should they be formatted in a specific way to get them to work? Thanks, Farrel