Seems like (at least) the API of #pos in ParserFunctions is
different from the one in StringFunctions.

{{#pos: haysack|needle|offset}}

While the StringFunctions #pos in MediaWiki 1.14 returned an
empty string when the needle was not found, the ParserFunctions
implementation of #pos in svn now returns -1.

This is most unfortunate since current usage depends on this.
Example:

{{#if: {{#pos: abcd|b}} | found | not found }}

{{#if: {{#pos: abcd|x}} | found | not found }}

Now both of these example will return "found"!


Usage scenario:

I try to use #pos in template calls to implement a sort-of-database
functionality in a mediawiki.

I have a big template that contains data in named parameters.
those parameters get passed along to a template that can select "columns"
by rendering some of those named parameters and ignoring others.

Now I want to implement "row selection" by passing along a parameter name
and a substring that should be in the value of that parameter in order
for the data to be rendered.

something like this:

{{#if: {{#pos: {{{ {{{selectionattribute}}} }}} | {{{selectionvalue}}} }} | 
render_row | render_nothing }}

If I want this to work in different MediaWiki installations I need
to rely on the API of #pos.

Currently there is seems to be no way to use #pos in a way that works 
on 1.14 and on 1.15-svn.

cheers
-henrik


_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to