Help:Parser functions in templates/ja

When applying ParserFunctions to template parameters, a pipe symbol ("|") may be used to provide a default value, which is used when a parameter is not defined. Used in an #if parser function, the unexpanded text from the undefined parameter will evaluate as true, which may be an unexpected result.


 *  


 * サンプル A:  


 * 結果: 


 *  


 * サンプル B:  


 * 結果: 

The second usage ( , sample B) with present empty default is often the desired way to handle situations where a parameter exists, but is comprised only of empty space.

Testing and passing undefined parameters
テンプレート呼び出しでパラメーターが指定されていたかどうかを調べる方法の 1 つは:



In rare cases, a template behaves differently when a parameter is unspecified compared to when it is specified but empty. When this template is used by a wrapper template (which uses the same set of named parameters), one way to ensure undefined parameters remain undefined is as follows (the technique also works with numbered parameters):



</dd></dl>

receives a defined normal_parameter in all cases. When normal_parameter is defined but empty and when it is undefined,  receives an empty normal_parameter.

By contrast, the  receives a defined sensitive_parameter only when it is indeed defined; when sensitive_parameter is undefined, the   changes the parameter name to sensitive_parameterNULL. The suffixed parameter name must be meaningless to the  for this to work properly.

関連項目

 * Extension:Loops#forargs
 * Extension:Loops#forargs
 * Extension:Loops#forargs