Search code examples
mediawikimediawiki-extensionsmediawiki-templates

Split string and map values, then join again


I use the external data-extension to load data from an external XML-source.

One of the variables contains a string that is separated with commas, for example:

Apple,Banana,Orange

I would like to transform this string to use it in the template. The resulting string should look like:

[[Apple]], [[Banana]], [[Orange]]

The amount of values in the string is not fixed, it varies from 1 to round about 20.

How can I do this? The #explode-function only allows access to a single specific value within the string.


Solution

  • Extension:Arrays can do what you want, so if you can install that https://www.mediawiki.org/wiki/Extension:Arrays

    If you can't install extensions you'll have no choice but to use {{#explode:}}