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"

Weight in the parser function

4
Wedhro (talkcontribs)

Hello, is it possible to specify a weight for options when using the parser function?

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

This is for the tags, is there none for the parser function?

Dinoguy1000 (talkcontribs)

Looking at the source code for the parser function, it doesn't appear so (though my PHP comprehension isn't especially strong).

Reply to "Weight in the parser function"

Parser function pipe syntax

2
24.49.246.169 (talkcontribs)

According to the parser function section, there should be a pipe before every choice including the first. However, on my wiki that leads to an empty choice being selected as often as any other result. Compare:

Why {{#choose:not|both}}?

and

Why {{#choose:|not|both}}?

several times to see for yourselves.

24.49.246.169 (talkcontribs)

I also couldn't find a way to specify the uncached parameter with this syntax.

Reply to "Parser function pipe syntax"

Since MediaWiki 1.33 entries starting with whitespace are treated as "code blocks"

2
Dinoguy1000 (talkcontribs)

For some reason after my wiki got updated to 1.33 all texts inside option tags starting with a whitespace are parsed as it happens when you start a new line beginning with a whitespace: a block in monospace font. Before, it just treated it as regular whitespace. I guess it's not intentional.Wedhro (talk) 17:46, 4 July 2019 (UTC)

Though this does not sound nice, no doubt, I think that this should be the expected behaviour. --[[kgh]] (talk) 21:52, 4 July 2019 (UTC)

This is indeed an intentional change, done to make the extension more cache-friendly. See the relevant commit.

(Pings just in case: @Wedhro:, @Kghbln:)

Bawolff (talkcontribs)

Well the commit has been reverted now, but my intention was not to change how the tag worked at all, so any changes to whitespace handling is accidental. Could you post an example of the change?

Reply to "Since MediaWiki 1.33 entries starting with whitespace are treated as "code blocks""
There are no older topics
Return to "RandomSelection" page.