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