ទំព័រគំរូ:If
{{ safesubst:p{{ safesubst:#if{{{1}}}:{{{2}}}|1|2}}|{{{3}}}|}}
With this template the parser functions of the ParserFunctions collection with names starting with "#if" can be used in a way such that they do not strip spaces and newlines from the "then" and "else" part. Spaces still do not affect the outcome of the condition.
Usage[កែប្រែ]
- {{if||x| p | q }} gives " p "
- {{if|expr|2<3| p | q }} gives " p "
- {{if|eq| u |u| p | q }} gives " p "
- {{if|exist| Help:Link | p | q }} gives " p "
- {{if|error|{{#expr:x}}| p | q }} gives " p "
Compare:
- {{#if:x| p | q }} gives "p"
- {{#ifexpr:2<3| p | q }} gives "p"
- {{#ifeq: u |u| p | q }} gives "p"
- {{#ifexist: Help:Link | p | q }} gives "p"
- {{#iferror:{{#expr:x}}| p | q }} gives "p"
For full substitution, use e.g. {{subst:if|expr|2<3| p | q |subst=subst:}}. If the condition contains a parser function or template etc., that should be substituted too. Optionally the "then" or "else" part can also be substituted.
See also[កែប្រែ]
ឯកសារកម្មខាងលើត្រូវបានសម្រង់ចេញពីទំព័រគំរូ:If/doc។ (កែ | ប្រវត្តិ) អ្នករៀបរៀងអាចពិសោធនៅទំព័រប្រអប់ខ្សាច់ (បង្កើត | ចម្លុះ) និង សំណុំល្បង (បង្កើត)របស់ទំព័រគំរូនេះបាន។ សូមបន្ថែមថ្នាក់ក្រុមទៅកាន់ទំព័ររង /doc។ ទំព័ររងនៃទំព័រគំរូនេះ។ |