Board Thread:Support Requests - Getting Technical/@comment-27704998-20160607002600/@comment-9605025-20160609003301

Here is a bit more on uses for #switch (Thread:1038287).

Yes, if you want it to work 100% properly you always have to use the #if statement. Just to be clear, it is:

Don't forget the "|"!

As for your confusion, I think it comes from your misunderstanding about how the parser functions work. #if and #switch do not interpret the input as a boolean (true/false) value. Instead, they treat the input as a string. In the case of #if, it can be though of as a boolean value that the functions itself generates based on the content of the string. In the case of #switch, it simply compares the string to the listed options to see if it matches. I suppose an equivalent in a lower level language would be something like. string mw_if(string input, string true_output, string false_output) { if (!only_white_space(input)) { return true_output; }   return false_output; }

string mw_switch(string input, string[] values, string[] outputs, string default) { num_choices = length(values); for (i = 0; i < num_choices; i++) { if (input == values[i]) { return outputs[i]; }   }    return default; } In both cases, "input" is determined by your template code. So if you do the first #switch example you listed, "input" is an empty string but not null. In your second example, your template code will attempt to get "input" from the invocation. If the invocation has "var=", then the template will use an empty string as "input". If the invocation has "var=something", then the template will use "something" as "input". If the invocation isn't given "var" at all, then the template will use "" as "input". The third example is very similar to the second with one difference. If the invocation isn't given "var" at all, then the template will use an empty string as "input". Note that by using "", the template will use "something" instead of an empty string if the case where the invocation is not given "var".