Template:SMW plain

From Yugipedia
Jump to: navigation, search
Template documentation[view] [edit] [history] [purge]

{{SMW plain}} can be used to strip [[SMW::off]] and [[SMW::on]] out of the result of an SMW query.

{{ #ask: [[Release::Yu-Gi-Oh! Duel Monsters (video game)]][[Card number::004]]
|?English name
| mainlabel = -
| format = template
| template = echo
| link = none
}}

The above query will produce the visual output, "Baby Dragon". However the underlying code will be [[SMW::off]]Baby Dragon[[SMW::on]]. This can be problematic when using string comparisons.

{{ #vardefine: $card_name
| {{ #ask: [[Release::Yu-Gi-Oh! Duel Monsters (video game)]][[Card number::004]]
  |?English name
  | mainlabel = -
  | format = template
  | template = echo
  | link = none
  }}
}}

{{ #ifeq: {{ #var: $card_name }} | Baby Dragon | true | false }}

For example, the above will produce false because [[SMW::off]]Baby Dragon[[SMW::on]] is not equal to Baby Dragon.

{{ #vardefine: $card_name
| {{SMW plain
  | {{ #ask: [[Release::Yu-Gi-Oh! Duel Monsters (video game)]][[Card number::004]]
    |?English name
    | mainlabel = -
    | format = template
    | template = echo
    | link = none
    }}
  }}
}}

{{ #ifeq: {{ #var: $card_name }} | Baby Dragon | true | false }}

If {{SMW plain}} is used around the outcome of the query, the [[SMW::off]] and [[SMW::on]] tagging will be removed and the above code will output true, as expected.