One of the most interesting “programming languages” I've recently stuck with is the MediaWiki templates. You can make an amazing amount of material with the limited syntax that they give you, but lately I have run into a problem that disgusts me: using string functions in template arguments. What I would like to do (somewhat simplified):
{{myTemp|a=1,2,3,4}}
then write a template that can do some kind of magic, for example
You told me _a_ starts with {{
Currently I can do this with inline javascript, grab the regex and document.write, but a) it is huge, b) it is hacked, and c) it will break badly if someone disables javascript. (Note that “split” is just an example, match, capture-regular expression match, etc. It would be even better)
I understand that the correct solution is for the caller to invoke the template with separate arguments, but for various reasons that would be difficult in my particular case. If this is simply not possible, I think the answer is, but if there is some way to get the templates to manipulate the string at the back end, that would be great.
string templates mediawiki wiki
Coderer
source share