Board Thread:Support Requests - Getting Technical/@comment-131168-20141129160252

Today I replaced an incredibly inefficient template with a bunch of exclusive if statements into a switch statement. That worked fine. I tried something to give even less repetition in the code and started having problems. The code as it works goes like

Though the real thing has many more entries. I tried to simplify things by turning it into

I worried that the pipe on the right side would make the switch statement think it was a new possibility being introduced, and that is what happened. So I tried the trick that's sometimes necessary for parser functions and replaced the pipe on the right with the ! template which just contains a pipe. So now the code looks like

This too didn't work. I added some nowiki into the template to see if the output looked right, and it did. I then made the target template simply output what it was getting for each parameter, and found the problem.

1 is Aikawa Maho 2 is 141004_003.jpg|S-mileage 3 is

Instead of switch output being sent as two consecutive parameters, it's now one parameter with a pipe in the middle. Is there something simple I'm missing? I can think of other solutions that would work (like a separate switch statement for each half), but they'd kind of go against my goal of cutting things down to as simple as possible. 