Help:Parser functions in templates/ja

テンプレートのパラメーターにパーサー関数を適用する際、既定値として空の文字列を指定するためにパイプ記号 (|) を使用できます. この既定値は、パラメーターを渡さない場合の対処法を示すために使用されます. In the absence of this, an undefined parameter will not expand (i.e. will expand to  ), which is not an empty string, and thus true.


 *  


 * サンプル 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.

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

 </tt>

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):

Note that the wrapped_template</tt> receives a specified but empty normal_parameter</tt> in two cases: when normal_parameter</tt> is specified and empty, and when normal_parameter</tt> is unspecified (because the default empty value is then specified by the wrapper template).

By contrast, the wrapped_template</tt> receives a specified sensitive_parameter</tt> only when it is indeed specified, because the #if</tt> changes the wrapped_template</tt> parameter name to « sensitive_parameterNULL</tt> » when sensitive_parameter</tt> is undefined.

Note also that wrapped_template</tt> receives a specified and empty sensitive_parameter</tt> only when the wrapper template receives a specified and empty sensitive_parameter</tt>. Of course, one must make sure the suffixed wrapped_template</tt> parameter name is meaningless to the wrapped_template</tt> for this to work properly.

関連項目

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