The string functions in the MediaWiki model?

One of the more interesting “programming languages” I’ve been stuck with lately is MediaWiki templates. You can do a surprising amount of stuff with the limited syntax they give you, but recently I’ve run into a problem that stumps me: using string functions on template arguments. What I’d like to do (somewhat simplified) is:


then write a template that can do some sort of magic like

You told me _a_ starts with {{#split:{{{a}}}, ",", 0}}

At present, I can do this with embedded javascript, capturing regexp matching, and document.write, but a) it’s huge, b) it’s hacky, and c) it will break horribly if anybody turns off javascript. (Note that “split” is merely an example; concatenate, capturing-regexp matching, etc., would be even better)

I realize the right
solution is to have the caller invoke the template with separate arguments, but for various reasons that would be hard in my particular case. If it’s simply not possible, I guess that’s the answer, but if there is
some way to have templates do string-manipulation on the back end, that’d be great.

Concatenate is easy. To assign x = y concat z


And, to add to Mark’s answer, there are also RegexParserFunctions

Ceterum censeo: MediaWiki will never be not hacky.

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » The string functions in the MediaWiki model?

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录