User:ChristTrekker/parserfuncs and parameters

What's going on here?
This is my test page to remind myself how template parameters, used with and without defaults, affect conditionals when the parameter is not given, given as a blank string, and given as a non-blank string.

The #if construct checks if a string is non-empty. (Empty means zero length, or consisting only of whitespace characters.) The #ifeq checks if two things are equal, as numbers if both are numeric, else as strings. The #switch construct matches the string to one of a selection of cases (again, numerically if both are numeric), or gives you a default for non-matches.

Demo
Case #1: If no parameter is given whatsoever:

Case #2: If a blank p is given:

Case #3: If p is given the value "present":

Analysis
In most cases, we probably want the non-given and blank-given cases to yield the same results. Two problems:


 * 1) When you try to display a parameter that was not given, you see the markup (e.g. ). "Easy enough," you say, "I'll supply a default value to display."
 * 2) But then you realize defaults only display when the value is not given. In other words, defaults only apply to unknowns—a blank is known. If you explicitly supply a blank value, as will often be the case when you supply a template blank for editors to copy-and-paste and fill in as needed, you don't get the "default" you may expect.

More to come .....