Topic on Extension talk:RandomSelection

Parameters not working in Option Weight

2
2600:4040:2923:1300:C00E:9ADA:72D:7C98 (talkcontribs)

I'm trying to create a template using the random selection. <choose> <option weight="{{#expr:1 + {{{add|0}}}}}>Apple</option> </choose>

But it returns nothing, making me think the expression is not being evaluated properly.

Dinoguy1000 (talkcontribs)

This is the standard "can't mix parser functions and XML-style tags" issue. You'll need to use #tag to work around this, though it's a bit more involved than usual since RandomSelection involves two tags:

{{ #tag: choose |
{{ #tag: option |Apple | weight="{{ #expr: 1 + {{{add|0}}} }}" }}
}}

(The whitespace in this code is generally optional and can be removed if you wish, but you shouldn't add any whitespace between each option and its preceding pipe, since this whitespace will be included in the output.)

Reply to "Parameters not working in Option Weight"