Şablon belgelemesi Belgeleme

Bu {{boşsa}} şablonudur.

Bu şablon diğer şablonların içinde kullanılmaktadır. It takes up to nine parameters (parameters 1-9), and returns the first one that is defined and non-empty, otherwise nothing. Typical usage is like this:

{{boşsa| {{{logo|}}} | {{{resim|}}} | default.svg }}

This returns the first of the parameters logo and image that is defined and non-empty, otherwise "default.svg".

Arka plan

The MediaWiki parameter default function doesn't return the default value for empty parameters. That is, {{{logo|default.svg}}} does not return "default.svg" if the template was called like this: {{template|logo=}}.

The usual workaround is to do like this:

{{#if:{{{logo|}}}| {{{logo}}} | default.svg }}

But this becomes complex when you want to check several parameters:

{{#if:{{{logo|}}}| {{{logo}}} | {{#if:{{{image|}}} | {{{image}}} | default.svg }}}}

Then it is easier to use this template instead:

{{boşsa| {{{logo|}}} | {{{image|}}} | default.svg }}

Not! The parameters to {{boşsa}} must use the pipe "|", like this: {{{logo|}}}. Or else {{boşsa}} will be fed and return the string "{{{logo}}}" if logo was not defined.

Örnekler

CodeResultComment
{{boşsa}} Returns an empty string.
{{boşsa|one}} one Returns the first parameter that is defined and not empty.
{{boşsa|one|two}} one
{{boşsa|one|two|three|four}} one
{{boşsa||two}} two The first parameter was empty or undefined, so uses the next parameter.
{{boşsa||two|three|four}} two
{{boşsa||two||four}} two
{{boşsa|||||||||nine}} nine
{{boşsa||||||||||ten}} Only handles up to nine parameters, so returns an empty string.
{{boşsa|}} The only parameter is empty or undefined, so returns an empty string.
{{boşsa||||}} Returns an empty string.
{{boşsa|{{{1|}}}|{{{2|}}}|three}} three
{{boşsa|{{{1}}}|{{{2}}}|three}} {{{1}}} Returns the text "{{{1}}}", because it is a non-empty string. Note the lack of "|" in the first two parameters.
{{boşsa|{{{logo|}}}|two}} two
{{boşsa|{{{logo}}}|two}} {{{logo}}} Returns the text "{{{logo}}}", because it is a non-empty string. Note the lack of "|" in the first parameter.
{{boşsa|2=x}} x Whether parameter 1 is undefined or empty does not matter.
{{boşsa|p=q}} The template checks its parameters 1-9, not other ones.

Ayrıca bakınız

  • {{px}} – Helps handling image width parameters in templates.
  • Help:Parameter default – You probably don't need to know this anymore if you use this template.